VistaDB Support Center

Start a new topic

Dataadapter multiple rows identity.

I have a routine that uses a dataadapter to insert multiple rows into a table, where the PK is an int IDENTITY.


I load the rows into a table of the dataset, and then post them using the update method in the dataadapter.  The end result is a successful posting of the rows, but the identity is DBNULL in the rows of the dataset.  Cannot figure out how to retrieve the identity for many rows.  If I do a "select @@identity" after the update I get back the ID of the last row.  That means this works if the rowcount in the dataset is 1 but not for >1,


How can I populate each row's newly-acquired identity value?

1 Comment

If you have a DDA connection and get the table's schema as an IVistaDBTableSchema, it has an Identities property which is indexed by column name to get the column's IVistaDBIdentityInformation.  The SeedValue property is the next Identity value to be used (but as a string).  If you check it before the insert it should give you the lower bound.  The StepExpression property (also as a string) is also important, but usually 1 (unless you used something else).


There doesn't seem to be a way to query it from SQL.

Login to post a comment