ADO.NET连接导致实例失败

Abd*_*man 2 c# sql-server ado.net

当我尝试使用ADO.NET建立与SQL Server的连接时,它显示错误.

这是我使用的代码:

SqlConnection con = new SqlConnection(@"Data Source=.\\SQLEXPRESS;Initial Catalog=abdul;uid=sa;pwd=sqlserver");
SqlCommand cmd = new SqlCommand();

con.Open();

String str="select * from emp where empname='Abdul'";
cmd = new SqlCommand(str, con);

SqlDataReader dr = cmd.ExecuteReader();

if (dr == null || !dr.HasRows)
{
   MessageBox.Show("No Records found");
}
else
{
   while (dr.Read())
   {
      textBox1.Text = dr[0].ToString();
      textBox2.Text = dr[1].ToString();
   }
}
Run Code Online (Sandbox Code Playgroud)

当我运行该项目时,它显示以下错误:

实例失败.

我需要做什么?

Pau*_*ulB 11

如果要使用@标记连接字符串以使其成为文字,则只应在数据源中使用一个反斜杠

数据源=\SQLEXPRESS