This should be painfully simple, but I cannot come up with a working connection string for a local copy of SQL Server 2008 using Windows Authentication. I've tried using the Data Link Properties tool to create a connection string and it has no problems connecting, but when I copy paste the generated string into my ADODB.Connection object's ConnectionString property I get all sorts of fun and different errors.
这应该很简单,但我无法使用Windows身份验证为SQL Server 2008的本地副本提供有效的连接字符串。我已经尝试使用数据链接属性工具来创建连接字符串,它没有连接问题,但当我复制粘贴生成的字符串到我的ADODB.Connection对象的ConnectionString属性时,我得到各种有趣和不同的错误。
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString = "SQLNCLI10.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=climb4acure;Data Source=(local);"
Microsoft OLE DB Service Components (0x80040E21) Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
Microsoft OLE DB服务组件(0x80040E21)多步OLE DB操作生成错误。检查每个OLE DB状态值(如果可用)。没有工作。
I've tried a variety of similar connection strings but I cannot find one that will work with Windows Authentication. Can someone point me in the right direction?
我尝试了各种类似的连接字符串,但我找不到可以使用Windows身份验证的连接字符串。有人能指出我正确的方向吗?
Thanks!
谢谢!
4 个解决方案
#1
11
I assume you have the 2008 Native Client installed? Also, I noticed that you're missing the "provider" tag at the beginning - do you have any more luck with this one:
我假设你安装了2008 Native Client?另外,我注意到你在开头就错过了“提供者”标签 - 你还有更多运气吗:
Provider=SQLNCLI10.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=climb4acure;Data Source=(local);
#2
32
Here's an easy way to generate connection strings that work.
这是生成有效连接字符串的简便方法。
-
Right-click an empty spot on the desktop and choose NEW, TEXT DOCUMENT from the context menu
右键单击桌面上的空白处,然后从上下文菜单中选择NEW,TEXT DOCUMENT
-
Save it with a .udl extension, and click yes when it asks are you sure.
使用.udl扩展名保存它,并在它确定时请单击“是”。
-
Double-click the new udl file you just created. It will open a dialogue. Go to the Provider tab, and choose the appropriate provider.
双击刚刚创建的新udl文件。它将开启对话。转到“提供程序”选项卡,然后选择适当的提供程序。
-
Go to the Connection tab and fill in the server name and database name, and choose NT authentication (or use a specific username and password, which is SQL authentication). Now click Test Connection. If it works, you're ready to click OK and move on to the final step. If it doesn't you need to resolve permission issues, or you've mis-typed something.
转到“连接”选项卡并填写服务器名称和数据库名称,然后选择“NT身份验证”(或使用特定的用户名和密码,即SQL身份验证)。现在单击Test Connection。如果有效,您可以单击“确定”继续执行最后一步。如果不是,您需要解决权限问题,或者您输入了错误的内容。
-
Now right-click the file on the desktop and open it in notepad. It will display the connection string that you can copy and paste to wherever you need it.
现在,右键单击桌面上的文件,然后在记事本中打开它。它将显示您可以复制并粘贴到您需要的任何位置的连接字符串。
#3
1
Have you had a look at connectionstrings.com? They are a pretty good reference (but, in my experience, they don't work too well in the Google Chrome browser).
你看过connectionstrings.com了吗?它们是一个非常好的参考(但根据我的经验,它们在Google Chrome浏览器中效果不佳)。
#4
0
Works absolutely fine:
工作绝对正常:
"Provider=SQLNCLI;Server=xxxxxxxx;uid=sa;pwd=xxxxxx;database=xxxxxx;"
“提供者= SQLNCLI;服务器= XXXXXXXX; UID = SA; PWD = XXXXXX;数据库= XXXXXX;”
#1
11
I assume you have the 2008 Native Client installed? Also, I noticed that you're missing the "provider" tag at the beginning - do you have any more luck with this one:
我假设你安装了2008 Native Client?另外,我注意到你在开头就错过了“提供者”标签 - 你还有更多运气吗:
Provider=SQLNCLI10.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=climb4acure;Data Source=(local);
#2
32
Here's an easy way to generate connection strings that work.
这是生成有效连接字符串的简便方法。
-
Right-click an empty spot on the desktop and choose NEW, TEXT DOCUMENT from the context menu
右键单击桌面上的空白处,然后从上下文菜单中选择NEW,TEXT DOCUMENT
-
Save it with a .udl extension, and click yes when it asks are you sure.
使用.udl扩展名保存它,并在它确定时请单击“是”。
-
Double-click the new udl file you just created. It will open a dialogue. Go to the Provider tab, and choose the appropriate provider.
双击刚刚创建的新udl文件。它将开启对话。转到“提供程序”选项卡,然后选择适当的提供程序。
-
Go to the Connection tab and fill in the server name and database name, and choose NT authentication (or use a specific username and password, which is SQL authentication). Now click Test Connection. If it works, you're ready to click OK and move on to the final step. If it doesn't you need to resolve permission issues, or you've mis-typed something.
转到“连接”选项卡并填写服务器名称和数据库名称,然后选择“NT身份验证”(或使用特定的用户名和密码,即SQL身份验证)。现在单击Test Connection。如果有效,您可以单击“确定”继续执行最后一步。如果不是,您需要解决权限问题,或者您输入了错误的内容。
-
Now right-click the file on the desktop and open it in notepad. It will display the connection string that you can copy and paste to wherever you need it.
现在,右键单击桌面上的文件,然后在记事本中打开它。它将显示您可以复制并粘贴到您需要的任何位置的连接字符串。
#3
1
Have you had a look at connectionstrings.com? They are a pretty good reference (but, in my experience, they don't work too well in the Google Chrome browser).
你看过connectionstrings.com了吗?它们是一个非常好的参考(但根据我的经验,它们在Google Chrome浏览器中效果不佳)。
#4
0
Works absolutely fine:
工作绝对正常:
"Provider=SQLNCLI;Server=xxxxxxxx;uid=sa;pwd=xxxxxx;database=xxxxxx;"
“提供者= SQLNCLI;服务器= XXXXXXXX; UID = SA; PWD = XXXXXX;数据库= XXXXXX;”