简体   繁体   中英

Remote connection to SQL server 2008 sp2

I built a window application in visual studio 2010. It is working fine at my computer. when I trying to run from another computer it gives me an Error: 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.

here some information : computer ip: 192.168.0.25 DNS - 192.168.0.12 instance - SQLEXPRESS

Connection string : String = "Data Source=192.168.0.12\\SQLEXPRESS;Initial Catalog=fleetInfo;User ID=user; Password=user123;"

Im running SQL Server Management Studio 2008 SP2. I checked sql server configuration Manager. Everything is fine. In configuration Manager> protocols for SQLEXPRESS > TCP/IP: IP1 IP address: 192.168.20.100 Port : null IP ALL Dynamic port : 1408 TCP port: null

I'm wondering what is wrong Im doing here.

Thanks guys.

If you are running the application on the same server as the SQL Instance you will need to reference that SQL instance rather than the IP of the server so your connection string should look something like Connection string : String = "Data Source=.\\SQLEXPRESS;Initial Catalog=fleetInfo;User ID=user; Password=user123;" when it is compiled and put on the server. For you to run it locally it will still need to be like you have it.

您似乎正在使用动态端口,因此必须在连接字符串中指定端口号(在您的情况下为1408): 192.168.0.12,1408

Your SQL Server configuration manager appears to indicate that your SQL Server's IP address is 192.168.20.100, not 192.168.0.12 which is in you connection string.

Also, the instructions in the SSWUG article couldn't have worked because it indicates to use the wrong adress in the telnet section.

So:

  1. Check config manager on the server again and verify the IP address and port (port may have changed)

  2. go to a command prompt (start / run / CMD.EXE) and type

     TELNET [ip address from config manager] [port from config manager] 

Do you get a black screen (indicating successful connection) or a failure message?

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM