views:

3385

answers:

4

When I go to the 'Add New Item' window in Visual Studio 2005 and try to add a SQL Database it hangs for a bit and then give 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: TCP Provider, error: 0 - No connection could be made because the target machine actively refused it.)

I can use SQL Server Management Studio to connection to localhost (default instance) just fine, but Visual Studio must be trying to connect to another instance (that isn't running anymore). How do I change what instance it tries to connect to in order to add and use the database?

+2  A: 

It sounds like you may be trying to add an instance of an SQL Server Express database but you may not have that service installed or turned on.

TheTXI
I am running SQL Server 2005 Express
Max Schmeling
Max: Are you positive that the service is running?
TheTXI
I can connect using SQL Server Management Studio
Max Schmeling
I marked this as the answer because it is the closest to correct... I did have SQL Express running, but it has to be running with SQLExpress instance (I had changed the instance name)... it is working now.
Max Schmeling
A: 

Expand the Servers node and remove the old server.

Ed Guiness
In server explorer? They are the same server (my box) just different instance. How do I know what it is trying to connect to?
Max Schmeling
remove both and start again
Ed Guiness
A: 

Do you get the warning dialog pointing at ... http://go.microsoft.com/fwlink/?LinkId=49251 ? My VS2005 dev machine has SQL Server Developer edition, but no SQL Express and I get that error when I try and add new SQL database

SteveC
That link just redirects me to microsoft.com/express... But I'd assume we're getting the same error
Max Schmeling
+1  A: 

Were you able to resolve this? I just spent 3 hours on the very same problem and can't say for sure what the solution was, but it works. My mistake was that the local SQL Server instance was not running when I 'upgraded' Visual Studio to the database edition. SQLExpress is not installed.

After starting the database, I initially got the same error as you when I tried to open existing database projects or create a new database project in Visual Studio. I googled it for a long time, tried all combinations of server, instance, host, alias, and other names for the design time validation database setting, all to no avail. It would not connect. I even reinstalled Visual Studio, which did not help, either.

I think what might have done the trick was a note in this msdn article - unload the project after changing this setting. I ended up clearing the field (for the default instance), unloaded the project, reloaded it, and violá, I am in business. Time to go to bed now.

cdonner