I am attempting to debug an application, but when I run it I get the following error message:
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)
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
I'm 90%sure there's something wrong with the connection string but I'm not sure what?
If you are not sure about the Connection string, use a udl file for testing:
1.txt
to 1.udl
) Connection
tab Allow saving password
check box Test Connection
and get a success message. 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...
Good luck!
试试这个代码
Data Source=xx.xx.xxx.xx;Initial Catalog=KnightOwl-Demo;Persist Security Info=True;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.