注册 登录
编程论坛 C# 论坛

运行报错:在位置 0 处没有任何行。怎么回事?

王和123 发布于 2021-05-29 21:24, 1251 次点击
程序代码:
private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                string num;
                string sqltext;
                num = textBox17.Text;
                sqltext = "select * from structure where num='" + num + "'";
                DataSet ds = new DataSet();
                ds = SQLHelper.GetDataSet(SQLHelper.str, CommandType.Text, sqltext, null);
                textBox16.Text = ds.Tables[0].Rows[0][1].ToString();
                textBox15.Text = ds.Tables[0].Rows[0][2].ToString();
                textBox14.Text = ds.Tables[0].Rows[0][3].ToString();
                textBox13.Text = ds.Tables[0].Rows[0][4].ToString();
                comboBox7.Text = ds.Tables[0].Rows[0][5].ToString();
                textBox12.Text = ds.Tables[0].Rows[0][6].ToString();
                comboBox6.Text = ds.Tables[0].Rows[0][7].ToString();
                textBox11.Text = ds.Tables[0].Rows[0][8].ToString();
                comboBox5.Text = ds.Tables[0].Rows[0][9].ToString();
                textBox10.Text = ds.Tables[0].Rows[0][10].ToString();
                textBox17.Text = ds.Tables[0].Rows[0][11].ToString();
            }
            catch (Exception)
            {

                throw;//此处报错
            }

        }
1 回复
#2
apull2021-05-29 22:35
么有查询到数据,看看你的num是什么类型的,数字不用加'
1