无法进行SQL连接

问题描述:

遇到麻烦进行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在所以不知道什么是错

+2

路径的价值是什么? – Mark

+0

变量“path”包含什么? –

这可能包括你所面临的问题...

msdn on sql express

对不起,链接BU t我不想复制粘贴别人的发现...