开发者

Unable to Make SQL Connection

开发者 https://www.devze.com 2023-04-05 16:46 出处:网络
Having Trouble making sql connection. this is my code private static SqlConnection GetConnection() { SqlConnection con = new SqlConnection();

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...

0

精彩评论

暂无评论...
验证码 换一张
取 消