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)
当我运行该项目时,它显示以下错误:
实例失败.
我需要做什么?
| 归档时间: |
|
| 查看次数: |
4091 次 |
| 最近记录: |