views:

449

answers:

1

I installed VS 2008 without SQL 2005, then I installed SQL 2008, then I needed 2005 express so I reinstalled VS checking the SQL feature. The installation went OK, however I still cannot open mdf files from VS. I think there is no 2005v instance installed.

When I dbl-click an mdf file in VS I get the following message: Connections to SQL Server Files (*.mdf) require SQL Server Express 2005 to function properly. Please verify the installation of the component or download from the URL: http:go.microsoft.com/fwlink/?linkID=49251.

Update

I tried to attatch it, it doesn't work. When I tried to attach it to SQL 2008 it doesn't work, when I try to attach it to SQL inside VS, I get the following error message: 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) I suspect that SQL 2005 doesn't have any instance at all. I opened SS manager and I didn't see any installed instances.

I don't know how to install an instance, or else if there is a way to open with 2008 tell me.

Any help will be really appreciated!

A: 

You don't just "open" an mdf file in Visual Studio - you need to "attach" the file to your SQL Server instance, then access it by creating a SQLConnection (System.Data.SQLConnection) from your VS application. See here for more info on attaching databases (note the FOR ATTACH option), and here's a good intro on accessing SQL Server data using a SQLConnection.

Oh, and if you should happen to see anything about "user instances", pretend you didn't. It was supposed to make auto-attaching databases easy (in fact, attaching databases isn't all that hard anyway). Microsoft is warning that the feature will be discontinued in later releases of SQL Server, so you're better off just learning the "right" way to do it.

Aaron Alton
I updated my question, please review
Shimmy