SQL连接问题
stringconStr=@"dataSource=.\Sqlexpress;AttachDbFilename=C:\ProgramFiles\MicrosoftSQLS...
string conStr = @"data Source=. \Sqlexpress; AttachDbFilename=C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA;
Integrated Security =true;";
SqlConnection con = new SqlConnection();
con.ConnectionString = conStr;
string SQL = "select * from student where no =' " + textBox1.Text + "'";
SqlCommand cmd = new SqlCommand();
cmd.CommandText = SQL;
cmd.Connection = con;
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
DataTable table = new DataTable();
table.Load(reader);
dataGridView1.DataSource = table;
con.Close();
这段代码没问题,万事为什么会出现在这个 呢??
求高人指点 展开
Integrated Security =true;";
SqlConnection con = new SqlConnection();
con.ConnectionString = conStr;
string SQL = "select * from student where no =' " + textBox1.Text + "'";
SqlCommand cmd = new SqlCommand();
cmd.CommandText = SQL;
cmd.Connection = con;
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
DataTable table = new DataTable();
table.Load(reader);
dataGridView1.DataSource = table;
con.Close();
这段代码没问题,万事为什么会出现在这个 呢??
求高人指点 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询