错误:位置0没有行 [英] Error: There is no row at position 0

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

问题描述

HI,我目前正在开发一个项目,当我运行该程序时,出现错误。它说这个



System.IndexOutOfRangeException未被用户代码处理

消息=位置0没有行。

来源=System.Data



StackTrace:



at System.Data.RBTree`1.GetNodeByIndex(Int32 userIndex)

at System.Data.RBTree`1.get_Item(Int32 index)

at System。 Data.DataRowCollection.get_Item(Int32 index)



...







请帮助....紧急....

i am currently working on a project, when i run the program, there is an error. It says this

System.IndexOutOfRangeException was unhandled by user code
Message="There is no row at position 0."
Source="System.Data"

StackTrace:

at System.Data.RBTree`1.GetNodeByIndex(Int32 userIndex)
at System.Data.RBTree`1.get_Item(Int32 index)
at System.Data.DataRowCollection.get_Item(Int32 index)

...



Please help....its urgent....

推荐答案

如果我没错,你正试图阅读或者从数据表中循环遍历行。此错误表明数据源(DataTable)没有任何行。为了避免这种异常,在阅读或循环数据表之前使用它:

If I am not wrong, you are trying to read or loop through the rows from datatable. This error states that the datasource(DataTable) is not having any rows. To avoid this exception use this before you read or loop through datatable:
if(dt.Rows.Count  > 0 ){
     //Do your stuff here.
}







--Amit




--Amit


这意味着您的查询没有返回任何结果。你总是需要进行防御性编码并在尝试索引之前检查Rows数组中是否有任何项目。
It means that no results were returned from your query. You always have to code defensively and check to see if the Rows array has any items in it before trying to index into it.


IndexOutOfRange 当您尝试访问(读/写)索引超出数组边界的数组元素时抛出异常



根据您的问题,我猜你是想读或写一些数组边界之外的数组元素。
IndexOutOfRange exception is thrown when you attempt to access (Read/ Write) an element of an array with an index which is outside the bounds of the array

As per your problem, I guess you are trying to read or write some array elements which are outside of your array boundary.


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

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