Get the identity value from an insert via a .net dataset update call

Posted by DeveloperMCT on Stack Overflow See other posts from Stack Overflow or by DeveloperMCT
Published on 2010-05-06T17:33:32Z Indexed on 2010/05/06 17:38 UTC
Read the original article Hit count: 221

Filed under:
|
|
|

Here is some sample code that inserts a record into a db table:

Dim ds As DataSet = New DataSet()
da.Fill(ds, "Shippers")

Dim RowDatos As DataRow
RowDatos = ds.Tables("Shippers").NewRow
RowDatos.Item("CompanyName") = "Serpost Peru"
RowDatos.Item("Phone") = "(511) 555-5555"
ds.Tables("Shippers").Rows.Add(RowDatos)
Dim custCB As SqlCommandBuilder = New SqlCommandBuilder(da)
da.Update(ds, "Shippers")

It inserts a row in the Shippers Table, the ShippersID is a Indentity value. My question is how can i retrieve the Identity value generated when the new row is inserted in the Shippers table.

I have done several web searches and the sources I've seen on the net don't answer it speccifically or go on to talk about stored procedures. Any help would be appreciated. Thanks!

© Stack Overflow or respective owner

Related posts about ADO.NET

Related posts about sql