我使用以下代码连接到Ms SQL-Server
var node_mssql = require('node-mssql');
/* add configuration to query object */
var queryObj = new node_mssql.Query({
host: '127.0.0.1', // You can use 'x.x.x.x\\instance' to connect to named instance
port: 1433,
username: 'myuser',
password: 'mypwd',
database: 'persondb'
});
/* set table name to operate */
queryObj.table('dbo.Person');
/* set update query condition */
queryObj.where({
'FirstName': 'Mathias',
})
/* run update query and fetch response */
queryObj.select(function(results) {
// success callback
console.log(results);
}, function(err, sql) {
// failed callback
if(err)
console.log(err);
console.log(sql);
});我得到了错误
Invalid object name "undefined.dbo.Person."
Select * FROM undefined.dbo.Person WHERE FirstName = 'Mathias'看起来servername没有被摘取。如何修复此问题以连接到Sql-Server?
发布于 2016-06-23 06:50:31
看起来您刚刚键入了一个不正确的参数名称(用db代替database):
var queryObj = new node_mssql.Query({
host: '127.0.0.1', // You can use 'x.x.x.x\\instance' to connect to named instance
port: 1433,
username: 'myuser',
password: 'mypwd',
db: 'persondb'
});https://stackoverflow.com/questions/33792031
复制相似问题