0
遇到麻煩進行SQL連接。這是我的代碼無法進行SQL連接
private static SqlConnection GetConnection()
{
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=" + path + @"\App_Data\Database1.sdf;Integrated Security=True;User Instance=True";
con.Open();
return con;
}
,這就是我得到
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.
而我的數據庫所在的文件夾的App_Data在所以不知道什麼是錯
路徑的價值是什麼? – Mark
變量「path」包含什麼? –