I have a DataTable with an "Id" column, which is an identity column in our SQL Server 2005 database. This column has the AutoIncrement property set to true. I don't fill the table with data from the DB, since I use it only for inserts, so it assigns bogus Ids starting from 1.
But after I call the tableAdapter.Update(), I'd like to have in that column the REAL Ids assigned by the database .
For some reason, only the first row gets updated, and all the rest not. This table references itself using a cascading DataRelation (hierarchical structure), and the references to the first row are also updated.
Please tell how do I make all the Ids updated accordingly.
Thanks in advance!
INSERT statement:
INSERT INTO Components (ComponentId, OrderNo, SerialNo)
VALUES (@ComponentId, @OrderNo, @SerialNo)
And here the schema of the Components Table:
Id BIGINT PK,
ComponentId BIGINT FK,
OrderNo int,
SerialNo int
Note that the Id column's name is "Id", "ComponentId" is the FK reference column.