471,071 Members | 1,173 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,071 software developers and data experts.

DataRow.Delete() throws System.ArgumentOutOfRangeException: Non-negative number required.

Hi,

When my code run to
DataRow.Delete()

It throws:

System.ArgumentOutOfRangeException: Non-negative number required.
Parameter name: length
at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array
destinationArray, Int32 destinationIndex, Int32 length)
at System.Data.Index.DeleteRecord(Int32 recordIndex)
at System.Data.Index.ApplyChangeAction(Int32 record, Int32 action)
at System.Data.DataTable.RecordStateChanged(Int32 record1,
DataViewRowState oldState1, DataViewRowState newState1, Int32 record2,
DataViewRowState oldState2, DataViewRowState newState2)
at System.Data.DataTable.SetNewRecord(DataRow row, Int32 proposedRecord,
DataRowAction action, Boolean isInMerge)
at System.Data.DataRow.Delete()


The datetable it belongs has a primary key:
DataColumn dcUserLoginName =new DataColumn(UserLoginName,
typeof(string));
dcUserLoginName.AllowDBNull = false;
this.currentQuotaUserDt.Columns.Add(dcUserLoginNam e);
this.currentQuotaUserDt.PrimaryKey = new DataColumn[] {dcUserLoginName};

Can someone tell me how could this happen and how to prevent it?
Thanks a lot!
Ryan
Jul 29 '06 #1
1 3100
Hello Ryan,

You're not allowed to delete data in a DataSet...no...no...no....I am kidding...

Any chance that DataTable has a DataView associated with it somewhere? I
have seen this happen when an errant DataView was created and hasn't been
collected.
Thanks,
Shawn Wildermuth
Speaker, Author and C# MVP
http://adoguy.com
Hi,

When my code run to
DataRow.Delete()
It throws:

System.ArgumentOutOfRangeException: Non-negative number required.
Parameter name: length
at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array
destinationArray, Int32 destinationIndex, Int32 length)
at System.Data.Index.DeleteRecord(Int32 recordIndex)
at System.Data.Index.ApplyChangeAction(Int32 record, Int32 action)
at System.Data.DataTable.RecordStateChanged(Int32 record1,
DataViewRowState oldState1, DataViewRowState newState1, Int32 record2,
DataViewRowState oldState2, DataViewRowState newState2)
at System.Data.DataTable.SetNewRecord(DataRow row, Int32
proposedRecord,
DataRowAction action, Boolean isInMerge)
at System.Data.DataRow.Delete()
The datetable it belongs has a primary key:

DataColumn dcUserLoginName =new DataColumn(UserLoginName,
typeof(string));
dcUserLoginName.AllowDBNull = false;
this.currentQuotaUserDt.Columns.Add(dcUserLoginNam e);
this.currentQuotaUserDt.PrimaryKey = new DataColumn[]
{dcUserLoginName};
Can someone tell me how could this happen and how to prevent it?

Thanks a lot!
Ryan

Jul 30 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Michael Carr | last post: by
5 posts views Thread by sdettmers | last post: by
3 posts views Thread by DBC User | last post: by
2 posts views Thread by =?Utf-8?B?TWFyYw==?= | last post: by
reply views Thread by =?Utf-8?B?SGFycnkgVg==?= | last post: by
1 post views Thread by Andy B | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.