各位大神帮帮忙吧 看看哪里错了
string constr = @"Data Source=.; Initial Catalog=liunian; Integrated Security=True";
string sql = "select * from studentInflo where studentNumber ='"+ textBox1.Text + "'";
MessageBox.Show(sql);
SqlParameter aaa = new SqlParameter("@id", textBox1.Text);
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand(sql, con))
{
cmd.Parameters.Add(aaa);
con.Open();
using (SqlDataReader rdr = cmd.ExecuteReader())
{
textBox2.Text = null;
while (rdr.Read())
{
for (int i = 0; i < rdr.FieldCount; i++)
{
textBox2.AppendText(rdr[i].ToString());
}
textBox2.AppendText("\r\n");
}
}
}
}