我遇到了以下错误:
以下是我使用mssql包连接SQL Server和Node.js的代码。
[ConnectionError: Login failed for user '****'.]
name: 'ConnectionError',
message: 'Login failed for user \'****\'.',
code: 'ELOGIN' } "
以下是我使用mssql包连接SQL Server和Node.js的代码。
var sql = require('mssql');
var config = {
server: "localhost\\",// You can use 'localhost\\instance' to connect to named instance
database: "***",
user: "***",
password: "",
port: 1433
};
function getdata() {
var conn = new sql.Connection(config);
var req = new sql.Request(conn);
conn.connect(function (err) {
If (err) {
console.log(err);
return;
}
req.query("select * From" ,function (err,recordset) {
If (err) {
console.log(err);
return;
}
else {
console.log(recordset);
}
conn.close();
enter code here
});
});
}
getdata();
当我将控制台添加到“conn”时,显示的消息如下,请告诉我是否有遗漏。
config:
{ server: '',
database: '',
user: '',
password: '',
port: 1433,
driver: 'tedious',
options: {},
stream: false,
parseJSON: false },
driver:
{ Connection:
{ [Function: TediousConnection]
EventEmitter: [Object],
usingDomains: false,
defaultMaxListeners: 10,
init: [Function],
listenerCount: [Function],
__super__: [Object] },
Transaction:
{ [Function: TediousTransaction]
EventEmitter: [Object],
usingDomains: false,
defaultMaxListeners: 10,
init: [Function],
listenerCount: [Function],
__super__: [Object] },
Request:
{ [Function: TediousRequest]
EventEmitter: [Object],
usingDomains: false,
defaultMaxListeners: 10,
init: [Function],
listenerCount: [Function],
__super__: [Object] },
fix: [Function] } }
started