[英]Connect to SQL Server Express edition from node.js driver mssql (Tedious wrapper)
TypeError [ERR_INVALID_URL]: Invalid URL:
类型错误 [ERR_INVALID_URL]:无效的 URL:
mssql://testuser:testuser@192.168.1.70\SQLEXPRESS/MyTestDBmssql://testuser:testuser@192.168.1.70\SQLEXPRESS/MyTestDB
The node package is: https://www.npmjs.com/package/mssql节点package为: https://www.npmjs.com/package/mssql
As per their Quick Example
根据他们的
Quick Example
await sql.connect('mssql://username:password@localhost/database')
I am doing this我正在这样做
await sql.connect('mssql://testuser:testuser@192.168.1.70\\SQLEXPRESS/MyTestDB');
My details are:我的详细信息是:
192.168.1.70\SQLEXPRESS
192.168.1.70\SQLEXPRESS
I have no issues connecting from SQL Server Management Studio from a remote machine, so what is the problem in this code?我从远程计算机从 SQL Server Management Studio 连接没有问题,那么这段代码有什么问题?
json object works, not plain string ! json object 有效,不是纯字符串!
let config = {
user: 'testuser',
password: 'testuser',
server: '192.168.1.70\\SQLEXPRESS',
database: 'MyTestDB'
}
Update: From a github issue it became clearer the Quick Example format is a Uri, not a connection string.更新:从 github 问题中可以清楚地看出,快速示例格式是 Uri,而不是连接字符串。
So instead of:所以而不是:
'mssql://testuser:testuser@192.168.1.70\\SQLEXPRESS/MyTestDB'
I should use the below, which I've since confirmed also works!我应该使用下面的,我已经确认它也有效!
'mssql://testuser:testuser@192.168.1.70/SQLEXPRESS/MyTestDB'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.