views:

228

answers:

3

I'm trying to practice using the ASP.NET MVC at home, but I ran into an impossible problem. I cannot open a connection to SQL Server 2008, I get this error: "Connections to SQL Server files (*.mdf) require SQL Server Express 2005 to function properly. ..."

I've googled around for numerous responses, none of them either working or addressing this issue. I'm running Vista 32-bit, my SQL Server 2008 Management Studio is also 32-bit, I have SP1 installed both on Visual Studio 2008 Professional, as well as the SQL Server. I changed the machine.config connectionStrings from ./SQLExpress to my SQL Server 2008 name.

Now if I connect manually through web.config, in an asp:datasource or code-behind, everything works fine. But for some reason trying to add a database Connection directly like this always gets the error. This is pretty fatal, since I can't rightly do much unless I can use LINQ to SQL with my MVC test project, and this is the only way I know how. Worked fine in school and work, but not at home.

Installing SQL Server Express 2005, as some have suggested, is not an option. Obviously it HAS to work with SQL Server 2008.

A: 

If your web app can talk to the database correctly, the problem isn't with the sql server or with your connection string, operating system, or what have you.

Make sure that SQL Management Studio is pointed at the correct instance of SQL Server Express on your box: see this thread on msdn social

David Lively
I tried pretty much everything in there. Add / Remove programs on SQL Server 2008 doesn't allow for changing the instance as per the 2005 instructions there. Changing it from the VS2008 Tools -> Options -> DBTools -> Data Connections does nothing. In SQL Server 2008 Mgmt Studio I can't find anything to change the instance.
Kahn
A: 

I assume you're using the AttachDBFileName=|DataDirectory|YourFile.mdf style of connecting to your SQL Server Express database, right??

The option of attaching a *.mdf file using AttachDBFile will only work with SQL Server Express - either in 2005 or 2008 versions. It's specifically an Express-only feature.

It does not work with the full versions (developer edition, web edition, standard edition, enterprise edition), and there is no switch or config or anything to enable that.

So if you actually want to use an attached .mdf file, you must use SQL Server Express - no way around that.

But if you already have a full version (non-Express version) of SQL Server installed - why not just install your database on that server, and use it from there?

Marc

marc_s
A: 

The error shows that there is nothing wrong with Visual Studio 2008. The database files you are trying to connect to are made in SQL Server 2005, are some how configured to run with SQL Server 2005 only.