1

I have Visual Studio 2008 and SQL Server 2008 Developer Edition installed on a Windows XP machine.

I get this error when trying to work on a Test Web 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)

My ADO.NET connection string is:

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\TestDB.mdf;Integrated Security=True;User Instance=True

Shouldn't a full install of SQL Server know how to handle SQL Express databases? Am I missing an install of something I need to work on an "attached" database? or do I still need to configure something? I think this has just worked for me (out-of-the-box) in the past.

update:
My intention is to use this as an Express DB even though I have a full-blown 2008 instance running. Can't you do this? Doesn't ASP.NET steer you towards one of these "express" databases by default when you try to use its Membership functionality?

3 Answers 3

3

Your SQL Server Developer edition doesn't use "SQLExpress" as the server name/instance - try using your server name or (local) instead.

Also, your string is inappropriate for an already-attached database. The string should look something like this:

connectionString="Data Source=(local);Initial Catalog=YourDatabaseName;IntegratedSecurity=True"

Update: ASP.NET won't steer you toward any particular database. In every way that really matters, all that ASP.NET cares about is that your connection string results fully and accurately describes the path and credentials needed to access some instance of SQL Server. Have you thought about trying out a more traditional connection string and then backing off one item at a time (e.g. naming the database file only after you've verified that the "normal" database connection runs correctly)?

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

3 Comments

Its not attached. I was trying to leave this as a SQL Express database so the data could "travel" with the project.
Yikes - given the kind of environment I work in, that is something I would just never run across! Good luck, I hope that my answer helped you somewhat.
Bruno - on thinking about it, I'm not sure what virtue comes from having your db "travel" as you say. SQL Server has to be installed anyway so why not just create the db via a script (or attach it via SMO) and then connect directly. I guess I'd need to know more about what you mean by "travel."
2

What version of SQl server did you install? That connection string is for the express edition and will not work for the other editions

see here for connection strings http://www.connectionstrings.com/

1 Comment

But don't you get the express "driver" capabilities with just a Visual Studio 2008 install?
0

Open up the SQL Server Management Studio

Look at the connection info it puts out when you log in.

Use that value in your connection string.

Make sure you have SQL Configuration to allow for connections.

One last thing to look at if the previous two steps don't help is to look at the firewall settings.

Comments

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.