Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB /SQL server and the identity column

Status
Not open for further replies.

grad

Programmer
Apr 13, 2000
15
US
I am using a ado recordset to insert a new record into a table in SQL server where the primary key is and integer identity column.&nbsp;&nbsp;Does anyone know how I can get the id that SQL assigned to the new record immediately after I call the update function:<br><br>rs.addnew<br>&nbsp;'do some work<br>rs.update<br>'<br>'<br>'how do I get the id<br>rs.fields(&quot;id&quot;)?????<br><br>rs.close<br><br>
 
You have to go back and re-get the record.&nbsp;&nbsp;Do a search on the data you just entered.&nbsp;&nbsp;That's what we did.
 
Alternately, you can create a stored procedure in SQL that returns the &quot;@@identity&quot; field which holds the newly created identity.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top