[英]ConnectionError: Failed to connect to localhost:undefined in 15000ms
I am using KnexJs attempting to connect to a local Microsoft SQL Server Express. 我正在使用KnexJs尝试连接到本地Microsoft SQL Server Express。 However, with the below configuration, I am getting an error.
但是,使用以下配置,我收到一个错误。 I've followed the typical steps, but I'm still getting the error.
我遵循了典型的步骤,但我仍然得到错误。
What I've tried: 我尝试过的:
Configuration / query code: 配置/查询代码:
let mssql = knex({
client: 'mssql',
connection: {
host: 'localhost\\sqlexpress',
user: 'test',
password: 'test',
database: 'AdventureWorks2017',
// port:1433,
// options: {
// trustedConnection: true
// },
useNullAsDefault: true
}
});
mssql.raw('select 1 as result').then(function (result) {
console.log('result');
console.log(result);
mainWindow.webContents.send('testConnectionResponse', result === 1);
event.sender.send('testConnectionResponse', result === 1);
}).catch(function (err) {
console.log(err);
mainWindow.webContents.send('query-error', err);
}).finally(() => {
mssql.destroy();
});
Error: 错误:
ConnectionError: Failed to connect to localhost:undefined in 15000ms
ConnectionError:无法连接到localhost:15000ms内未定义
It turns out that I also needed to enable the SQL Server Browser windows service like so: 事实证明,我还需要启用SQL Server Browser Windows服务,如下所示:
Success! 成功!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.