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.
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.
I renamed the file under C:, but now I'm getting an error:
"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."
Please note: I'm trying to OPEN the database and not trying to create it.
So what am I doing wrong? Did I misunderstand something? How do these database file work (I mean, how to use them)?