简体   繁体   中英

sql connection not working after Windows 6 app moved from local to server

I have a Windows 6 app I am developing (in VB). I am pulling data from a MSSQL 2005 database. Everything worked fine running it locally (with an emulator) but when I moved the database to a test box, I get the following error:

System.Data.SqlClient.SqlException {"Specified SQL server not found: xx.xx.xx.xxx\\sql2005"}

My connection string is:

Data Source=XX.XX.XX.XXX\sql2005;Initial Catalog=databaseName;UID=databaseUser;PWD=password

The only difference in the connection string from when I was running it locally is I used my computer name (which I also tried using the name of the sqlserver computer).

Thanks

make sure sql browser is running

make sure remote connections and TCP/IP is enabled on the SQL box

Try changing your connection string to:

Data Source=XX.XX.XX.XXX;Initial Catalog=databaseName;UID=databaseUser;PWD=password

Most likely the Instance Name (sql2005) is incorrect.

Gordon's idea was close. The instance name (sql2005) was correct, as I could get there with the same connection string from a web app of mine, but for some reason wouldn't work with the mobile app. When I moved the database from that instance onto just that box (so xx.xx.xx.xxx with no /sql2005) it worked.

Is the app running on the same server as the DB? Have you tried using "localhost"?

Definitely look to make sure that remote connections are enabled on the SQL Box as SqlMenace suggested.

If SQL Server is configured to allow remote connections & TCP/IP is enabled, try running the app on the database server to see if it works correctly. If it doesn't work, it would indicate that there is something wrong with the connection string.

If running the app locally on the database server works, and remote connections \\ TCP/IP are enabled, try this article concerning Windows Firewall and SQL Server.

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