I try to add a database file to my project and am told it exists already

  • Thread starter Thread starter Gidmaestro
  • Start date Start date
G

Gidmaestro

Guest
I copied a SQL SERVER MDF file to my app_data folder in my Visual Studio project and tried to connect, but got this error when the code opens the database connection.

System.Data.SqlClient.SqlException
HResult=0x80131904
Message=An attempt to attach an auto-named database for file
C:\gideonwroteprograms2\EchoTheory\EchoTheory\bin\Debug\App_Data\EchoDatabase.mdf
failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

A possible clue:

A few weeks ago I tried to connect create the same database from within the server explorer window, and then run a script to populate its tables. That did work, but since then I had to reinstall visual studio, and the program supposedly no longer finds that database, but when I put an MDF version in the app_data folder, maybe its finding somehow that old version and raising an error about duplication? Or is there another problem?

Thanks

Continue reading...
 
Back
Top