[英]ConnectionError: Failed to connect to localhost:undefined in 15000ms
我正在使用KnexJs嘗試連接到本地Microsoft SQL Server Express。 但是,使用以下配置,我收到一個錯誤。 我遵循了典型的步驟,但我仍然得到錯誤。
我嘗試過的:
配置/查詢代碼:
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();
});
錯誤:
ConnectionError:無法連接到localhost:15000ms內未定義
事實證明,我還需要啟用SQL Server Browser Windows服務,如下所示:
成功!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.