I have installed SQL Server 2008 R2 Express on Windows 7.
When I run a web project in VS2010 I receive the following 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. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Strange, I am working on the local machine (VS2010, IIS, SQL Server, etc. no network needed).
I googled around and followed many tips. Nothing helps.
I use the correct instance name (e.g. like Data Source=PCName\SQLServer;Initial Catalog=SampleDBName;Integrated Security=True
)
Gave the Network Service the right credentials, etc. etc. etc.
I am lost now and having this problem for a week now. Pulling my hair out!
Update:
I got a tip to test my connection string with SQL Server Management Studio Express. In the Connect popup screen you usually use the Login tab (first and default tab). You can also use the third tab 'Additional Connection Parameters'. I tested my connect string and it just works fine!
So, I think it's something with rights. But I have no idea what or which ...
O yeah. Some extra info. I changed Application pools default options for IIS 7.5 from 'ApplicationPoolIdentity' to 'NetworkService'. I added the Network Service as login to SQL, gave grant rights, etc. I turned SQL Browser service on, the service is running (but it is not really necessary because I run local).
Update 2:
It's seems like I found what causes the error, but I have no clue why.
For my website I created a website with some virtual folders and applications. I need an url in my logic. Therefor I use a host header (like http://server.name.tld)
In VS2010 I configured Property pages -> start options -> use custom web server with the url (same as the earlier mentioned host header).
If I do that I get the error.
If I use use Property pages -> start options -> default web server, it seems that I get a connection to the db.
But I need the use of the host header.
What do I need to do, to get the 'custom web server' working?
Update 3:
Tried today also with a test virtual machine with windows server 2008. Still getting the error.
Also made a test web application, without an IIS site an without a host-header. That one works just fine (using the same connectstring). Also on the VM.
I am lost. I really need someone who can exchange some knowledge to me in this field ...