VB6 和 Sql 服务器 2016 Express 连接字符串

VB6 and Sql server 2016 Express connection string

在我们的一个旧的vb6 app连接字符串如下:

nk = "Provider=SQLOLEDB;"
nk = nk + "Integrated Security=SSPI;"
nk = nk + "Persist Security Info=False;"
nk = nk + "User ID=sa;"
nk = nk + "Password=******;"
nk = nk + "Initial Catalog=" & db & ";"
nk = nk + "Data Source=" & hn
kon.ConnectionString = nk
kon.Open

如果我尝试连接这些选项,它不会起作用,所以我很想知道为什么这两个选项:

nk = nk + "Integrated Security=SSPI;"
nk = nk + "Persist Security Info=False;"

没有被忽略?

只需提及该应用程序正在通过本地网络连接到 Windows Server 2016 Standard 上的 Sql Server 2016 Express。

你的问题是

Integrated Security=SSPI

它应该设置为 false(或完全删除),因为您使用的不是当前的 Windows 用户身份验证,而是标准的 SQL 用户密码登录。

出于 MSDN documentation

When false, User ID and Password are specified in the connection. When true, the current Windows account credentials are used for authentication. Recognized values are true, false, yes, no, and sspi (strongly recommended), which is equivalent to true. If User ID and Password are specified and Integrated Security is set to true, the User ID and Password will be ignored and Integrated Security will be used.