database 经典 ASP - 使用 Windows 身份验证的 SQL Server 2008 连接字符串
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1359579/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Classic ASP - SQL Server 2008 Connection String using Windows Authentication
提问by Nathan Taylor
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 Service Components (0x80040E21)
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
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!
谢谢!
回答by Mike
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
Save it with a .udl extension, and click yes when it asks are you sure.
Double-click the new udl file you just created. It will open a dialogue. Go to the Provider tab, and choose the appropriate provider.
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.
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.
右键单击桌面上的空白处,然后从上下文菜单中选择新建、文本文档
使用 .udl 扩展名保存它,并在询问您确定时单击是。
双击刚刚创建的新 udl 文件。它将打开一个对话。转到提供程序选项卡,然后选择适当的提供程序。
进入Connection选项卡,填写服务器名和数据库名,选择NT认证(或者使用特定的用户名和密码,也就是SQL认证)。现在单击测试连接。如果它有效,您就可以单击“确定”并继续执行最后一步。如果不需要解决权限问题,或者您输入了错误的内容。
现在右键单击桌面上的文件并在记事本中打开它。它将显示连接字符串,您可以将其复制并粘贴到您需要的任何位置。
回答by SqlRyan
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);
回答by Paul Hanbury
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 浏览器中效果不佳)。
回答by Arvind Kumar
Works absolutely fine:
工作得很好:
"Provider=SQLNCLI;Server=xxxxxxxx;uid=sa;pwd=xxxxxx;database=xxxxxx;"
“提供者=SQLNCLI;服务器=xxxxxxxx;uid=sa;pwd=xxxxxx;数据库=xxxxxx;”