c#应用程序,一个简单的问题。
我用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();
if (sql == "not ")
{
checkBox1.Checked = true;
}
else
{
checkBox1.Checked = false;
}
}
.
.
.
if (i == 12)
{
comboBox48.Visible = true;
comboBox47.Visible = true;
comboBox46.Visible = true;
comboBox45.Visible = true;
checkBox12.Visible = true;
comboBox48.Text = rd1[ "Note "].ToString();
comboBox47.Text = rd1[ "jstj "].ToString();
comboBox46.Text = rd1[ "zhi "].ToString();
comboBox45.Text = rd1[ "ljtj "].ToString();
string sql;
sql = rd1[ "shifou "].ToString();
if (sql == "not ")
{
checkBox12.Checked = true;
}
else
{
checkBox12.Checked = false;
}
}
rd1.Close();
sqlconn.cn.Close();
[解决办法]
no question
[解决办法]
[解决办法]
少了个}吧