我是node.js的新手,需要帮助连接SQL服务器
我有以下node.js代码
var express = require('express');
var app = express();
app.get('/', function (req, res) {
var sql = require("mssql");
// config for your database
var config = {
user: 'sa',
password: 'Amtex123',
server: 'LAPTOP-7ACI67I5',
database: 'TData',
port: 1433
};
// connect to your database
sql.connect(config, function (err) {
if (err) console.log(err);
enter code here
// create Request object
var request = new sql.Request();
// query to the database and get the records
request.query('select * from credentials', function (err, recordset) {
if (err) console.log(err)
// send records as a response
res.send(recordset);
});
});
});
var server = app.listen(3000, function () {
console.log('Server is running..');
});
我收到错误消息
ConnectionError:无法连接到LAPTOP-7ACI67I5:1433 - 无法连接(序列)
在Connection.tedious.once.err(C:\ Projects \ nodejs \ node_modules \ mssql \ lib \ tedious.js:216:17)
在Object.onceWrapper(events.js:315:30)
在emitOne(events.js:116:13)
在Connection.emit(events.js:211:7)
在Connection.socketError(C:\ Projects \ nodejs \ node_modules \ tedious \ lib \ connection.js:869:14)
在C:\ Projects \ nodejs \ node_modules \ tedious \ lib \ connection.js:739:25
在SequentialConnectionStrategy.connect(C:\ Projects \ nodejs \ node_modules \ tedious \ lib \ connector.js:153:9)
在Socket.onError(C:\ Projects \ nodejs \ node_modules \ tedious \ lib \ connector.js:169:16)
在emitOne(events.js:116:13)
在Socket.emit(events.js:211:7)
代码:'ESOCKET',**
我检查了各种解决方案和