Home All Groups Group Topic Archive Search About

Bug adding identity column to an existing DataTable

Author
30 Mar 2007 7:29 AM
SoftLion
Hi all,
I'm trying to add a kind of "identity" column into an existing DataTable of
a DataSet:
I'm using this code but the new column doesn't fill as expected with an
incremented value.
Any idea ?

DataSet ds = ...
....
DataColumn identity = new DataColumn( "ROWINDEX", typeof(int) );
identity.AutoIncrement = true;
identity.AutoIncrementSeed = 0;
identity.AutoIncrementStep = 1;
ds.Tables[0].Columns.Add( identity );

When  I inspect the value in the ROWINDEX column of each row, it looks
random and the same value appears in different rows !!
Any idea ?

AddThis Social Bookmark Button