string strsql = @"Data Source=LINDUN-PC\\SQLEXPRESS;Initial Catalog =student;Integrated Security = True;";
SqlConnection con = new SqlConnection(strsql);if(con.State==ConnectionState.Open)
{
   MessageBox.show("数据库打开")
}
出现的错误:con.Open()实例失败,为什么会出现这样的错误?

解决方案 »

  1.   

    string strsql = @"Data Source=.\SQLEXPRESS;Initial Catalog =student;Integrated Security = True;";
      

  2.   

    server=.;Integrated security=true;database=dataName  最简单的
      

  3.   

    string strsql = @"Data Source=LINDUN-PC\\SQLEXPRESS;Initial Catalog =student;Integrated Security = True;";本机用.
    .\SQLEXPRESS你已经用@,就不要两个\