急!急!异常详细信息: System.IndexOutOfRangeException: 在位置 9 处没有任何行。
For k = 0 To ds2.Tables(0).Rows.Count - 1
tagnam = Trim(ds2.Tables(0).Rows(k)("tagnam")) '循环表里的n个位号
sqlstr10 = "select * from AVER_VALUE where TAGNAM = '" & tagnam & "' and (DRDATE between to_date('" & Trim(Tx_SDate.Text) & "','yyyy-mm-dd') and to_date('" & Trim(Tx_EDate.Text) & "','yyyy-mm-dd')) and PLANT='" & j & "' " 'or PART='" & j & "'
ds5 = GetDataFromOracle(sqlstr10) '取k位号里的其他值
plant = ds5.Tables(0).Rows(k)("PLANT")
descr = ds5.Tables(0).Rows(k)("DESCRIBE")
part = ds5.Tables(0).Rows(k)("PART")
sqlstr8 = "select distinct CLASSNAME from AVER_VALUE where TAGNAM = '" & tagnam & "' and (DRDATE between to_date('" & Trim(Tx_SDate.Text) & "','yyyy-mm-dd') and to_date('" & Trim(Tx_EDate.Text) & "','yyyy-mm-dd')) and PLANT='" & j & "' " 'or PART='" & j & "'
ds4 = GetDataFromOracle(sqlstr8) '平均值表里不同的班组
p = ds4.Tables(0).Rows.Count
For h = 0 To ds4.Tables(0).Rows.Count - 1
classname = Trim(ds4.Tables(0).Rows(h)("CLASSNAME")) '循环表里的n个班组
sqlstr6 = "select sum(AVER_VALUE) from AVER_VALUE where TAGNAM = '" & tagnam & "' and CLASSNAME = '" & classname & "' and (DRDATE between to_date('" & Trim(Tx_SDate.Text) & "','yyyy-mm-dd') and to_date('" & Trim(Tx_EDate.Text) & "','yyyy-mm-dd')) and PLANT='" & j & "' "
Dim cm2 As New OracleCommand(sqlstr6, conn)
sum = cm2.ExecuteScalar
sqlstr7 = "select * from AVER_VALUE where TAGNAM = '" & tagnam & "' and CLASSNAME = '" & classname & "' and (DRDATE between to_date('" & Trim(Tx_SDate.Text) & "','yyyy-mm-dd') and to_date('" & Trim(Tx_EDate.Text) & "','yyyy-mm-dd')) and PLANT='" & j & "' "
ds3 = GetDataFromOracle(sqlstr7) '某一位号一段时间内的n个值
count2 = ds3.Tables(0).Rows.Count
aver = sum / count2
addstr = "insert into AVER_VALUE_LS values ('" & plant & "','" & descr & "','" & tagnam & "'," & aver & ",'" & part & "','" & classname & "',to_date('" & Trim(Tx_SDate.Text) & "','yyyy-mm-dd'),to_date('" & Trim(Tx_EDate.Text) & "','yyyy-mm-dd'))"
Oraclecommand(addstr)
Next
Next
在此位置处 plant = ds5.Tables(0).Rows(k)("PLANT")报异常详细信息: System.IndexOutOfRangeException: 在位置 9 处没有任何行。
但是我的数据库里确实有值,不是每个时间段都报错,有的报、有的不报。
各位有没有碰到过这种情况的,请回贴啊。。。。。。。。。。。。。。。