Note that there are some explanatory texts on larger screens.

plurals
  1. POsql server mdf file database attachment
    text
    copied!<p>I'm having a bear of a time getting visual studio 2010 (ultimate I think) to properly attach to my database. It was moved from it's original spot to <code>#MYAPP#/#MYAPP#.Web/App_Data/#MDF_FILE#.mdf</code>. I have three instances of SQL Server running on this machine. I have tried to replace the old mdf file with my new one and cannot get the connectionstring right for it. </p> <p>What I'm really trying to do is to just open a DB instance and run a DB create script. Then I can have a DB that was generated via my edmx (generate database from model) in Silverlight business application (c#)</p> <p>Right now, when I go to Server Explorer in VS, choose add new connection, choose MS SQL Server Database File (SqlClient), choose my file location (app_data directory), use Windows authentication, and hit the Test Connection button, I get the following error:</p> <blockquote> <p>Unable to open the physical file "". Operating system error 5: "5(Access Denied.)". An attempt to attach to an auto-named database for file"" failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.</p> </blockquote> <p>The mdf file was created on the same machine by </p> <ul> <li>Connecting to (local) in SQL Server management studio.</li> <li>Getting a new query. </li> <li>Pasting in the SQL from the generated ddl file.</li> <li>Adding <code>CREATE DATABASE [NcrCarDatabase]; GO;</code> before the pasted SQL and</li> <li>Executing the query. </li> </ul> <p>I then </p> <ul> <li>Disconnected from the DB in Management Studio.</li> <li>Closed Management Studio</li> <li>Navigated to the DATA directory for that instance</li> <li>Copied the mdf and ldf files to my application's app_data folder. </li> </ul> <p>I am now trying to connect to the same file inside visual studio. </p> <p>I hope that gives more clarity to my problems :).</p> <p>Connection string is:</p> <blockquote> <p>Data Source=.\SQLEXPRESS;AttachDbFilename=C:\SourceCode\NcrCarDatabase\NcrCarDatabase.Web\App_Data\NcrCarDatabase.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload