Create SQL Database and add to project using Visual Studio

14,595

Solution 1

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.

Solution 2

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.

Share:
14,595
Max Schmeling
Author by

Max Schmeling

Node.js and Ruby on Rails web and back-end developer.

Updated on June 04, 2022

Comments

  • Max Schmeling
    Max Schmeling almost 2 years

    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?