我试图通过某种原因获取虚拟路径.... \无法浏览目录。
SqlConnection sqlConnectionCmdString = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=..\..\database\ClientRegit.mdf;Integrated Security=True;User Instance=True");
答案 0 :(得分:0)
试试这个:
AttachDbFilename=|DataDirectory|\database\ClientRegit.mdf
答案 1 :(得分:0)
SqlConnection sqlConnectionCmdString = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename="+ Application.StartupPath+ @"\database\ClientRegit.mdf;Integrated Security=True;User Instance=True");