SQL连接字符串无法连接SQL实例 [英] SQL Connection String failing to connect SQL Instance
问题描述
我正在尝试调试应用程序,但是当我运行它时,出现以下错误消息:
I am attempting to debug an application, but when I run it I get the following error message:
建立与SQL Server的连接时发生与网络相关或特定于实例的错误.服务器未找到或无法访问.验证实例名称正确,并且已将SQL Server配置为允许远程连接.(提供者:SQL网络接口,错误:26-指定服务器/实例时出错)
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
我已经打开了1433端口,并仔细检查了它的开放性,并且可以从当前位置访问该端口.我还启用了TCP/IP远程连接,并可以使用SQL Server Studio Manager进行远程连接.
I've opened up the 1433 port and double-checked it's open and reachable from my current location. I've also enabled TCP/IP remote connections and can connect remotely using SQL Server Studio Manager.
我正在使用的连接字符串是:
The connection string I'm using is:
Data Source=xx.xx.xxx.xx, 1433;Network Library=DBMSSOCN;Initial Catalog=KnightOwl-Demo;Persist Security Info=True;User ID=KnightOwlGentleshaw; Password=xxxxxx
我确定90%的连接字符串有问题,但是我不确定是什么?
I'm 90%sure there's something wrong with the connection string but I'm not sure what?
推荐答案
如果不确定连接字符串,请使用udl文件进行测试:
If you are not sure about the Connection string, use a udl file for testing:
- 创建一个新的文本文件.
- 将扩展名更改为 .udl (例如,将
1.txt
更改为1.udl
) - 转到"
连接
"标签 - 插入您的凭据(服务器名\实例,用户名和密码/Windows安全性等)
- 选中
允许保存密码
复选框 - 单击
测试连接
并获得成功消息. - 单击确定"(这将关闭表格)
- 在文本编辑器中打开
1.udl
文件-该文件将包含用于成功连接的连接字符串
- Create a new text file.
- Change the extension to .udl (e.g.
1.txt
to1.udl
) - Go to the
Connection
tab - Insert your credentials (Servername\instance , user name + password / Windows security etc)
- Check the
Allow saving password
check box - Click on
Test Connection
and get a success message. - Click on OK (this will close the form)
- Open the
1.udl
file in a text editor - It will contain the connection string that was used for the successful connection
现在您可以比较连接字符串/使用您现在可以使用的连接字符串...
Now you can compare the connection strings / use the one you now that works...
祝你好运!
这篇关于SQL连接字符串无法连接SQL实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!