Having Trouble making sql connection. this is my code
private static SqlConnection GetConnection()
{
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=.\SQLEXPRESS;Attach开发者_StackOverflow中文版DbFilename=" + path + @"\App_Data\Database1.sdf;Integrated Security=True;User Instance=True";
con.Open();
return con;
}
and this is what i get
Error: An attempt to attach an auto-named database for file \App_Data\Database1.sdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
And my database is located in a folder App_Data so not sure whats wrong
This might cover the issues you are facing...
msdn on sql express
Sorry for the link but I didn't want to just copy paste someone elses findings...
精彩评论