title: SQL Server: loading database file
body: <p>I'm using SQL Server 2008. I should be able to "connect" to a user-specified database file (mdf) (using the AttachDbFilename section of the connection string) and save a copy of the selected file. I also have to work with the contents of the database.</p>
  
  <p>If I got it right, a single mdf file represents a complete database with tables, stored procedures, etc. But then, if I have two files with the same name in different folders (one in the DATA folder of SQL Server and the other in the root of C:), and I try to load the file under C: I get an error stating that a database already exists with that name.</p>
  
  <p>I renamed the file under C:, but now I'm getting an error:</p>
  
  <blockquote>
    <p>"CREATE FILE encountered operating system error 5(failed to retrieve
    text for this error. Reason: 15105) while attempting to open or create
    physical file 'C:/myDatabaseFile_log.ldf'.   Could not open new
    database 'C:/MYDATABASEFILE.MDF'. CREATE DATABASE is aborted.   An
    attempt attach an auto-named database for file 'C:/myDatabaseFile.mdf'
    failed. A database with the same name exists or specified file cannot
    be opened, or it is located on UNC share."</p>
  </blockquote>
  
  <p>Please note: I'm trying to OPEN the database and not trying to create it.<br>
  So what am I doing wrong? Did I misunderstand something? How do these database file work (I mean, how to use them)?</p>