That is my code:
那是我的代码:
var express = require('express');
var http = require('http');
var app = express();
var sql = require('mssql');
var path = require('path'),
html5 = require('ejs').__express;
app.set('port', process.env.PORT || 3000);
app.engine('.html', html5 );
app.set('views', __dirname + '/views');
app.set('view engine', 'html');
http.createServer(app).listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});
var config = {
user: 'dbo',
password: '',
server: 'localhost',
database: 'db_name'
}
sql.connect(config, function(err) {
// ... error checks
// Query
var request = new sql.Request();
request.query('select * from table_name', function(err, recordset) {
// ... error checks
console.log(recordset);
app.get('/', function(request, response) {
response.send(err);
});
});
});
In console recordset set me the message: "undefined" and in localhost:3000 the message is: "Login failed; one or more errorMessage events should have been emitted" I'm using MSSQLSERVER 2012. Thanks for the answers.
在控制台记录集中为我设置了消息:“undefined”,在localhost:3000中,消息是:“登录失败;应该发出一个或多个errorMessage事件”我正在使用MSSQLSERVER 2012.感谢您的答案。
1 个解决方案
#1
1
After many days, I decided to connect MSSQL Server with PHP because I thought was easiest but I found the same problem: Login failed. Then I was trying to connect and saw the real trouble: Windows auth. Conclusion: the right way to work with module mssql is sql server auth and available port 1433.
多天后,我决定将MSSQL Server与PHP连接,因为我认为最简单,但我发现了同样的问题:登录失败。然后我试图连接并看到真正的麻烦:Windows身份验证。结论:使用模块mssql的正确方法是sql server auth和可用端口1433。
//e.g.:
var config = {
user: 'sa',
password: '******',
server: 'ip_server',
database: 'db_name'
}
#1
1
After many days, I decided to connect MSSQL Server with PHP because I thought was easiest but I found the same problem: Login failed. Then I was trying to connect and saw the real trouble: Windows auth. Conclusion: the right way to work with module mssql is sql server auth and available port 1433.
多天后,我决定将MSSQL Server与PHP连接,因为我认为最简单,但我发现了同样的问题:登录失败。然后我试图连接并看到真正的麻烦:Windows身份验证。结论:使用模块mssql的正确方法是sql server auth和可用端口1433。
//e.g.:
var config = {
user: 'sa',
password: '******',
server: 'ip_server',
database: 'db_name'
}