views:

1591

answers:

1

When I try to add a new Sql Server Database file to my Visual Studio project, it tells me that I need to have Sql Server 2005 Express installed even though I have Sql Server 2005 Developer already? Is this by design and if so, why did Microsoft do it? and if it is not by design, what is the solution to fix it?

+3  A: 

If you are going to add a database to your project, it is going to try and add one of the SQL Express type. If you are using an actual SQL Server 2005 instance running, you want to CONNECT to it, you can't just add it to your project.

What you will want to do is add a connection string (it will contain the basic connection info including location, database name, authentication properties, etc.) in your web.config and then you will be able to reference that connection string when trying to open a connection to the database.

Edit: You can use W3 Schools and their ASP.NET database tutorial for more information.

Edit 2: The author of the question asked a good follow-up in the comments and I wanted to make sure this was visible to future viewers without having to scour the comments.

The question Xaisoft posed was "Just out of curiosity. What if you don't want to add a connection, but you want to add a database? Do we have a choice?"

Answer: When you try to add a database, you are trying to add a full-blown database that will remain with the project regardless of where it is hosted (given that the host can run SQL Server Express instances). If you want to do that, you need to have SQL Server Express installed.

Connecting to a database will allow you to point to the location of an existing SQL Server 2005 database anywhere (as long as you can properly authenticate). I should also mention that regardless of what method you use, you will still need to learn about connecting.

Even if you have a SQL Server Express DB packaged with your project, you will still need to use connectionstrings to establish a connection to that database so that you can then use queries and such on it.

TheTXI
Just out of curiosity. What if you don't want to add a connection, but you want to add a database? Do we have a choice?
Xaisoft
Xaisoft: When you try to add a database, you are trying to add a full-blown database that will remain with the project regardless of where it is hosted (given that the host can run SQL Server Express instances). If you want to do that, you need to have SQL Server Express installed.
TheTXI
Xaisoft: Connecting to a database will allow you to point to the location of an existing SQL Server 2005 database anywhere (as long as you can properly authenticate). I should also mention that regardless of what method you use, you will still need to learn about connecting.
TheTXI
Xaisoft: Even if you have a SQL Server Express DB packaged with your project, you will still need to use connectionstrings to establish a connection to that database so that you can then use queries and such on it.
TheTXI
Ok, Thanks for all the info.
Xaisoft