DataTable.NewRow problem

  • Thread starter Thread starter Steve Amey
  • Start date Start date
S

Steve Amey

Hi All

I have a DataTable that has the AutoIncrement properties set, but when I add
a new row it doesn't use the values I'd expect and is causing an error.

For example:

MyTable.Columns("PKColumn").AutoIncrement = True
MyTable.Columns("PKColumn").AutoIncrementSeed = -1
MyTable.Columns("PKColumn").AutoIncrementStep = -1

Dim oRow As DataRow = MyTable.NewRow
'// oRow("PKColumn") = 12 I'd expect it to be a negative figure, and for
each Row I add it decreases by 1
MyTable.Rows.Add(oRow) '// Causes error the second row that's added cos the
PK value already exists amd is unique.

Has anyone else experience this??

Regards,
Steve.
 
If you have statement like MyDataAdapter.FillSchema(MyDataSet,
SchemaType.Mapped, "MyTable") running before, you cannot change PKColumn's
property in MyTable.
 
Hi John

I don't have anything like that running before I can see the properties of
the Column in the Locals window and they are correct, but when I create a
New Row it doesn't create the row with the PK column as a negative.

Regards,
Steve.
 
Back
Top