I have a program works fine in .NET 1.1 and just recompiled in .NET 2.0
without any code change. Compiles OK, but there is an exeception when
execute it.
Then I remove PK, it works all fine again.
Is this a known bug : PK on auto increase DataColumn in DataTable cause
NullReferenceEx ception?
dcLineId = new DataColumn(LINE ID_STR,
System.Type.Get Type("System.In t32"));
dt.Columns.Add( dcLineId);
dcLineId.AutoIn crement = true;
dcLineId.AutoIn crementStep =1;
//if I remove this line, it works OK again on VS 2005
this.dt.Primary Key = new DataColumn[] {dcLineId};
.......
this.dt.Rows.Ad d(dr); //execute first time OK, second time throws
NullReferenceEx ception
NullReferenceEx ception
at System.Data.Ind ex.CompareRecor ds(Int32 record1, Int32 record2)
at System.Data.Ind ex.IndexTree.Co mpareNode(Int32 record1, Int32 record2)
at System.Data.RBT ree`1.RBInsert( Int32 root_id, Int32 x_id, Int32
position)
at System.Data.Ind ex.InsertRecord (Int32 record, Boolean fireEvent)
at System.Data.Ind ex.ApplyChangeA ction(Int32 record, Int32 action)
at System.Data.Dat aTable.RecordSt ateChanged(Int3 2 record1,
DataViewRowStat e oldState1, DataViewRowStat e newState1, Int32 record2,
DataViewRowStat e oldState2, DataViewRowStat e newState2)
at System.Data.Dat aTable.SetNewRe cordWorker(Data Row row, Int32
proposedRecord, DataRowAction action, Boolean isInMerge, Int32 position,
Boolean fireEvent, Exception& deferredExcepti on)
at System.Data.Dat aTable.InsertRo w(DataRow row, Int32 proposedID, Int32
pos, Boolean fireEvent)
at System.Data.Dat aRowCollection. Add(DataRow row)
...........
Thanks,
~.~.~.~.~.~.~.~ .~.~.~.~.~.~.~. ~.~.~.~.
Ryan Liu
137 0173 5101
Shanghai Fengpu Software Co. Ltd
Shanghai , China
http://www.PowerCATI.com Powerful CATI!
http://www.fpsoft.net.cn
~.~.~.~.~.~.~.~ .~.~.~.~.~.~.~. ~.~.~.~.