我用while循环,最多能查找到6条记录,如果满足条件的记录多于6个,则提示:
阅读器关闭时 MetaData 的尝试无效。
string sqlstr1 = "select * from bb_chaxuntj where sql= ' " + ww + " ' ";
SqlCommand cmd1;
SqlDataReader rd1;
sqlconn.cn.Close();
sqlconn.cn.Open();
cmd1 = new SqlCommand(sqlstr1,sqlconn.cn);
rd1 = cmd1.ExecuteReader();
int i = 0;
while (rd1.Read())
{
i = i + 1;
if (i == 1)
{
comboBox1.Text = rd1[ "Note "].ToString();
comboBox2.Text = rd1[ "jstj "].ToString();
comboBox3.Text = rd1[ "zhi "].ToString();
comboBox4.Text = rd1[ "ljtj "].ToString();
label10.Text = rd1[ "常用查询组合 "].ToString();
string sql;
sql = rd1[ "shifou "].ToString();