Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

"An attempt to attach an auto-named database for file C:UsersJohndocumentsvisual studio 2010ProjectsPASPASinDebug//PatAddSys.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."

What's wrong here? I have the correct code for my path ( I think) but still this error occurs here is my database path

private string dbPath = Application.StartupPath + "//PatAddSys.mdf";

Here's the location of My Database

enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
342 views
Welcome To Ask or Share your Answers For Others

1 Answer

Try setting the User Instance property in your connection string to true. You need to add this to your connection string:

User Instance=True

Also just to be sure check again your database server as it might already contain a database with the same name.

Hope that helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...