DataTable.NewRow problem

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.
 
G

Guest

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

Steve Amey

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top