简体   繁体   中英

connectionstring in web.config

I have a connection string at web.config. The data source is " .\\SQLEXPRESS " This works fine on local machine, but when I published the website using vs and an error occurred about sql connection.

I think there is some problem with ".". Then I changed it to an IP Address, after that error occurred on both the local and remote machine.

I think the problem lies on the expression of data source. Can anyone help me resolve this?

The error is:

Server Error in '/' Application. 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)

The use of "." is simply a shortcut for "localhost". You must verify that there is a SQLEXPRESS named instance on the machine you are deploying to. If this is not the case, you must specify an appropriate data source. You mentioned using an IP Address which will work, but that will again require an accessible endpoint at that location.

For more help, see the following:

http://www.sqlmusings.com/2009/03/11/resolving-a-network-related-or-instance-specific-error-occurred-while-establishing-a-connection-to-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