Home All Groups Group Topic Archive Search About

Adding identity column to an existing DataTable

Author
29 Mar 2007 1:25 PM
SoftLion
Hi all,
I'm trying to add an identity like column into an existing table of a
DataSet:

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 seems
random (and the same value appears in different rows !!)
Any idea ? (using framework 1.1 with latest SP)

Author
30 Mar 2007 4:30 PM
gfergo@gmail.com
SoftLion,

Can you post a little more code?

How was the DataTable created?

How are you "inspecting" the rows?

Thanks!




Show quote
On Mar 29, 9:25 am, "SoftLion" <nos***@replyToGroup.com> wrote:
> Hi all,
> I'm trying to add an identity like column into an existing table of a
> DataSet:
>
> 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 seems
> random (and the same value appears in different rows !!)
> Any idea ? (using framework 1.1 with latest SP)

AddThis Social Bookmark Button