Problem with creating .MDF file from Visual Studio 2010
10,688
Check to make sure the SQLExpress service is running.
From a command prompt:
sc query mssql$sqlexpress
If the state returned is "1 STOPPED", then start the service with
sc start mssql$sqlexpress
Related videos on Youtube
Author by
profanis
Updated on June 04, 2022Comments
-
profanis over 1 year
I am trying to create a small wpf application by using mdf.
The problem is that when I am trying to add new service-based database (.mdf) I am getting the error "Connection to SQL Server database files (.mdf) require SQL Server 2005 Express or SQL Server 2008 Express to be installed and running on the local computer. The current version of SQL Server Express can be downloaded at the following url (link)".
The SQL Server 2008 is already been installed.
What am I doing wrong?
-
marc_s almost 13 yearsThe "attach an .mdf" option is only available in the EXPRESS editions of SQL Server - all the others (web, standard, enterprise) do NOT support this option. If you have a "full" version of SQL Server, you need to create the database on the server, and then connect to it using a server connection string - you cannot simply attach a .mdf file with the full versions of SQL Server
-
Andy almost 13 years@marc_s When you say "attach an .mdf" is this the same as going to Add New Item > Data > SQL Server Database? Usually this would create a .mdf database in the project but it isn't working for me as per the same issue. As with OP, I have the full version of SQL server installed not express. Is this really the problem? Do you know if this is discussed anywhere on MSDN docs at all? Just finding it really hard to understand the reasoning behind only having this functionality in Express and not the Full edition. Does this not seem a bit insane to anyone else?
-
marc_s almost 13 years@Andy: just because... it's a marketing thing - no technical reason. But the fact is: if you want to use a "full" version of SQL Server, you cannot just create it from within Visual Studio as a separate file - you need to go into SQL Server Management Studio and create it on the SQL server itself, and then connect to it from within Visual Studio.
-
Andy almost 13 yearsActually, is it because this particular usage of SQL server (single instance) is being deprecated? - stackoverflow.com/questions/3487067/…
-
Andy almost 13 years@marc_s Ah, fair so, it'll just be one of those things I'll have to accept and move on! :) Only reason why I cared so much was cause I wanted to see what the 'Asp.net website' database schema was like, doesn't seem to be anywhere on MSDN.
-
-
profanis almost 13 yearsI forgot to mention in my initial post, that the service is running
-
profanis almost 13 yearsThe services are running properly.
-
Jesse McCulloch almost 13 yearsDid you actually install the express edition with VisualStudio, or did you skip it and install the full version of SQL
-
marc_s almost 13 years@StrouMfios: The EXPRESS part is the important thing! Attaching the .MDF will NOT work with other editions of SQL Server
-
profanis almost 13 yearsFirstly I install the ful version of sqlServer and afterwards I install the sqlExpress.