添加新行时抛出ArgumentOutOfRangeException [英] throw ArgumentOutOfRangeException when add new row

查看:977
本文介绍了添加新行时抛出ArgumentOutOfRangeException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我遇到问题,当我在DataRowCollection中调用方法Add(MyDataSet.DTProject.Rows.Add(row))时,我得到了一个例外  ArgumentOutOfRangeException。

I have a problem, when i call method Add (MyDataSet.DTProject.Rows.Add(row)) in DataRowCollection, i got an exception the ArgumentOutOfRangeException.

消息摘要:  索引超出范围。必须是非负数且小于集合的大小。  参数名称:index

Message summary:  Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

StackTrace:    at System.ThrowHelper.ThrowArgumentOutOfRangeException()

    at System.Collections.Generic.List`1.RemoveAt(Int32 index)

    at System.Data.RecordManager.NewRecordBase()

    at System.Data.DataTable.NewRecord(Int32 sourceRecord)

    at System.Data.DataRow.BeginEditInternal()

    at System.Data.DataRow.set_Item(DataColumn column,Object value)

StackTrace:    at System.ThrowHelper.ThrowArgumentOutOfRangeException()
   at System.Collections.Generic.List`1.RemoveAt(Int32 index)
   at System.Data.RecordManager.NewRecordBase()
   at System.Data.DataTable.NewRecord(Int32 sourceRecord)
   at System.Data.DataRow.BeginEditInternal()
   at System.Data.DataRow.set_Item(DataColumn column, Object value)

推荐答案

你能再展示一下你的代码吗?
Can you show a little more of your code?


这篇关于添加新行时抛出ArgumentOutOfRangeException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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