0

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)

2
  • Can you please post the actual error you are having? Commented Dec 28, 2011 at 18:32
  • is SQLExpress on your remote machine? Commented Dec 28, 2011 at 18:55

1 Answer 1

3

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/

Sign up to request clarification or add additional context in comments.

5 Comments

The "." can be replaced by local or the host name of server. I wonder can it can replaced by the ip address?
It can, but as the error message states, you must "Verify that the instance name is correct and that SQL Server is configured to allow remote connections."
I checked the sqlexpress the service is on. I also started sql server browser, and enabled TCP/IP protocol for sqlexpress
Have you verified firewall rules? The following link may help you: sqlmusings.com/2009/03/11/…
Yes, actually I disabled the entire firewall. Now the it only works when I run it on visual studio "start debugging" .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.