Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a physical machine running win8, and two VMs in hyper-v client: 1 web server, 1 sql server. The web server works fantastic. The sql is the one that is giving me the problem. I can connect to it with server explorer in visual studio or management studio just fine, and it's blazing fast.

The problem happens when I use the same connection string I am using in visual studio server explorer in the web.config for an app.

data source=VMSQL1;initial catalog=OtherShell;persist security info=True;user id=OtherShell;password=****;network library=dbmssocn;MultipleActiveResultSets=True;App=EntityFramework

I made sure it was also using tcp-ip, but it doesn't connect with or without the network library part of the connection string.

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)

This is driving my batty for the last two days, any ideas? It fails from the web vm too, but works in management studio with the same connection string.

share|improve this question
    
What port is SQLServer listening on? The default is 1433, but sometimes the installation uses a 'dynamic port' -- very irritating. From an elevated command prompt on the SQLServer VM, run netstat -nba and see what port SQLServer is LISTENING. If it isn't 1433, read the second thread posted by Vince in reply to this blog: blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provi‌​der-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error‌​/ –  James L. Sep 10 '12 at 17:11
    
SQL is on port 1433, and port is open on firewall. –  Rick Ratayczak Sep 11 '12 at 0:50
add comment

2 Answers

The problem was in the web.config. The membership and role providers were using a non-existent "LocalProvider" connection string, I added a and it fixed it.

share|improve this answer
add comment

This is an example of the connection sting I use. Data Source=[YourIP];User ID=[YourUserID];Password=[YourPassword];Initial Catalog=[YourDatabase];Provider=SQLNCLI10.1 Hope that helps.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.