sql >> Databasteknik >  >> RDS >> Sqlserver

SQL Server-anslutning till nod js

Sätt din var req = new sql.Request(conn) inuti ansluta.

// config for your database
var config = {
    user: 'sa',
    password: 'mypassword',
    server: 'localhost', 
    database: 'SchoolDB' 
};

// connect to your database
sql.connect(config, function (err) {

    if (err) console.log(err);

    // create Request object
    var request = new sql.Request();

    // query to the database and get the records
    request.query('select * from Student', function (err, recordset) {

        if (err) console.log(err)

        // send records as a response
        res.send(recordset);

    });
});


  1. OSX 10.9 Mavericks och Eclipse Kepler (4.3.2) eller M6 Eclipse Luna (4.4)

  2. Twisted adbapi:runInteraction last_insert_id()

  3. konvertera sträng till datum php

  4. Oracle UpdateXML() ändrar XML-struktur?