R
Ryan Liu
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(dcUserLoginName);
this.currentQuotaUserDt.PrimaryKey = new DataColumn[] {dcUserLoginName};
Can someone tell me how could this happen and how to prevent it?
Thanks a lot!
Ryan
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(dcUserLoginName);
this.currentQuotaUserDt.PrimaryKey = new DataColumn[] {dcUserLoginName};
Can someone tell me how could this happen and how to prevent it?
Thanks a lot!
Ryan