我正在尝试使用node-mssql包连接到SQL Server。
我可以使用以下配置成功连接到默认数据库:
{
"user": "service_user",
"password": "myPass",
"server": "10.2.xxx.xxx",
}
但是,我想连接多个数据库。当我尝试将连接配置为以特定数据库为目标时,会失败:
{
"user": "service_user",
"password": "myPass",
"server": "10.2.xxx.xxx",
"database": "Q-xxx-SQL-xxx\\DB2"
}
我也尝试过这种配置,但也失败了:
{
"user": "service_user",
"password": "myPass",
"server": "10.2.xxx.xxx\\Q-xxx-SQL-xxx",
"database": "DB2"
}
当我尝试连接到特定的数据库时,出现以下错误:
{ ConnectionError: Login failed for user 'service_user'.
at ConnectionError (/Users/name/Desktop/SCIM API-MSSQL/node_modules/tedious/lib/errors.js:13:12)
at Parser.tokenStreamParser.on.token (/Users/name/Desktop/SCIM API-MSSQL/node_modules/tedious/lib/connection.js:735:29)
at Parser.emit (events.js:189:13)
at Parser.parser.on.token (/Users/name/Desktop/SCIM API-MSSQL/node_modules/tedious/lib/token/token-stream-parser.js:27:14)
at Parser.emit (events.js:189:13)
at addChunk (/Users/name/Desktop/SCIM API-MSSQL/node_modules/readable-stream/lib/_stream_readable.js:297:12)
at readableAddChunk (/Users/name/Desktop/SCIM API-MSSQL/node_modules/readable-stream/lib/_stream_readable.js:279:11)
at Parser.Readable.push (/Users/name/Desktop/SCIM API-MSSQL/node_modules/readable-stream/lib/_stream_readable.js:240:10)
at Parser.Transform.push (/Users/name/Desktop/SCIM API-MSSQL/node_modules/readable-stream/lib/_stream_transform.js:139:32)
at doneParsing (/Users/name/Desktop/SCIM API-MSSQL/node_modules/tedious/lib/token/stream-parser.js:80:14)
message: 'Login failed for user \'service_user\'.',
code: 'ELOGIN' },
name: 'ConnectionError' }
登录运行DB的服务器时,可以成功地在SSMS中读写目标DB。