English 中文(简体)
我为什么经常听到这一错误的信息?
原标题:Why do I get this error message very often?
  • 时间:2010-05-11 06:13:28
  •  标签:
  • vb.net

"There is no row at position 0." Hi I keep on getting this error message.

If mytable.Rows.Count >= 0  then
dim  myid = dt.Rows(0).Item(6).ToString
End if

在这方面,请帮助我,我永远不会再看到这一信息。 谢谢大家。

qry_Sql = qry_Sql + " select SRNO,EMPNO,ATTN_YR,ATTN_MONTH,"
    qry_Sql = qry_Sql + " GRP,TOT_HRS,MY_ID "
    qry_Sql = qry_Sql + " from ATTD_HRS  "
    qry_Sql = qry_Sql + " ORDER BY EMP_NO "

    If mytable.Rows.Count <= 0 Then
    mygrp = dt.Rows(0).Item(5).ToString ---------------------
    myid = dt.Rows(0).Item(6).ToString 
    End If 
最佳回答

Probably because mytable has no row at position 0, (rows(0) part). You should check if there are rows/items before using them.

问题回答

您应检查您的表格是否载有任何段落。

If mytable.rows.Count > 0 then
    If mytable.rows(0).items(2) >= 0 then
        dim  myid = dt.Rows(0).Item(6).ToString
    End if
End if




相关问题
Is Shared ReadOnly lazyloaded?

I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? ...

Entertaining a baby with VB.NET

I would like to write a little application in VB.NET that will detect a baby s cry. How would I get started with such an application?

Choose Enter Rather than Pressing Ok button

I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn t do the "Ok". Instead I have to manually click on Ok ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

Hover tooltip on specific words in rich text box?

I m trying to create something like a tooltip suddenly hoovering over the mouse pointer when specific words in the richt text box is hovered over. How can this be done?

热门标签