IndexOutofRangeException :There is no row at position 0

前端 未结 1 441
别跟我提以往
别跟我提以往 2021-01-22 07:52

I am trying to design a mini project of a quiz application using resource bundle. I get an error of There is no row at position 0 when I insert the following

相关标签:
1条回答
  • 2021-01-22 08:26

    There are no rows in ds.Tables["QA"].

    You need to check if there is a row you want to read before attempting it:

    if (recno < ds.Tables["QA"].Rows.Count)
        textBox1.Text = ds.Tables["QA"].Rows[recno].ItemArray[2].ToString();
    
    0 讨论(0)
提交回复
热议问题