I am accessing a service based database by using the following connection string
static string appath = Library_Records.Program.app_path;
string connectionstring = @"Data Source=.\SQLEXPRESS;AttachDbFilename=appath;Integrated Security = true;User Instance = True";
connection = new SqlConnection(connectionstring);
static string dbfiles = null;
internal static string app_path
{
get { return dbfiles = "|Datadirectory|\\5700.mdf"; }
}
Library_Records:namespace, Program is the class name containing Main()
When I call connection.Open(), it gives the following error
An attempt to attach an auto-named database for file appath failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
5700 is my database with .mdf extension. How to rectify this problem?