Adding AutoIncrement column to table does not increment

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

After retrieving a table from SQL. I wanted to add a column to the table with
a record id. After retrieving the data and then I add the column and set the
following properties:

dt.Columns.Add("NewColumn", GetType(Int32))
dt.Columns("NewColumn").AutoIncrement = True
dt.Columns("NewColumn").AutoIncrementSeed = 0
dt.Columns("NewColumn").AutoIncrementStep = 1

Nothing happens. I looked through the records for this column and there is
nothing there.

I am using ADO.NET 1.0 and Visual Studio.NET 2002...

I have seen examples for this and I am wondering if its not supported with
the earlier version of ADO.NET. Or I am doing something wrong.

Thanks.
 
I found that it will only fill the incremented data only if you add the
column to the datatable before you fill the datatable with data. On the
examples I have seen the column can be added after the data has been filled.
Why is this? I would rather be able to add the increment column after my
datatable has been filled..
 
Back
Top