存在行,但是错误“在位置(0)没有行". [英] Row exists but error "there is no row at position(0)"

查看:139
本文介绍了存在行,但是错误“在位置(0)没有行".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

我的程序中有以下代码块-

Dear friends,

I have the following code block in my program-

dim RowPostion as integer 
If dt.Rows.Count > 0 Then
  MsgBox(dt.Rows(RowPostion)(0).ToString) 
  MsgBox(dt.Rows(RowPostion )(1).ToString) 
  dt.Rows.RemoveAt(RowPostion) 
End If



问题是,我能够读取值,但无法删除.尝试删除该行时,它返回"position(..)没有行".


我找不到任何解决方法.
关于这个问题,您能帮我吗?

SKPaul.



Problem is, i am able to read values, but fail to delete. It returns "There is no row at position(..)" while trying to remove the row.


I cound not find any solution.
Would you please help me regarding this issue?

SKPaul.

推荐答案

我希望问题是因为您没有为行位置指定起始值

试试这个
I hope the problem is because you didn''t specified a starting value for the row position

try this
Dim RowPosition as integer = 0
If dt.Rows.Count > 0 Then
  MsgBox(dt.Rows(RowPostion)(0).ToString)
  MsgBox(dt.Rows(RowPostion )(1).ToString)
  dt.Rows.RemoveAt(RowPostion)
End If




(如果RowPosition以1开头,请首先检查数据行计数和Row位置的值,然后尝试将Row位置的值退回到其原始位置)




(First check the value of data row count and Row position then try to set the value of Row position one step back to its original position, if the RowPosition is starting with 1)


这篇关于存在行,但是错误“在位置(0)没有行".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆