Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have two sql databases that are created in a same way and they are in the same path.
i can open one but in opening another one i got this error:

An attempt to attach an auto-named database for file xxx.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share
thank you for any advice.
Posted

Check your login information. Very often, you get that message because the login ID you are using does not have sufficient permissions.
 
Share this answer
 
Comments
4L4K1 15-Nov-14 11:52am    
they have same connection string except database file name.
OriginalGriff 15-Nov-14 11:57am    
Can you share the two connection strings? Just replace the password with "XXX" for security.
4L4K1 15-Nov-14 12:07pm    
they are connection string in App.config file

connectionstring="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\bin\Debug\db\dbBackup.mdf;Integrated Security=True;Connect Timeout=30" providername="System.Data.SqlClient"
connectionstring="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\bin\Debug\db\db.mdf;Integrated Security=True;Connect Timeout=30" providername="System.Data.SqlClient"
4L4K1 15-Nov-14 12:12pm    
I do not know about sql connection but it makes me crazy because i can open the connection to db.mdf but can not open the connection to dbBackup.mdf
they are in the same path . they are created in the same way. oh my god!
OriginalGriff 15-Nov-14 12:19pm    
Have you checked the folder? Are there any other files called "dbBackup" or "db" in the data directory? Do the the original files exist?
the problem was this :
mdf file was not included in project.(i fond it in Solution Explorer windows)
i used relative path (AttachDbFilename=|DataDirectory|...)in connection string and it makes problem.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900