"An attempt to attach an auto-named database for file C:\Users\John\documents\visual studio 2010\Projects\PAS\PAS\bin\Debug//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
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.