Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

How to return the primary key value of a just inserted row in vb.net and asp.net

$
0
0

Hi 

I want to retrieve the primary key value of a row i just inserted.  The primary key values are automatically generated. I want to insert that primary key value into another table as a foreign key.

This is the code to insert data in 1st table

       Core.DB.DoQuery("insert into survey(id,title, detail,employerid,userid) values(@id,@title, @detail, @eid, @uid);", Core.DB.SIP("title", surveyTitle.Text), Core.DB.SIP("detail", surveyDetail.Text), Core.DB.SIP("eid", LocalHelper.UserEmployerID()), Core.DB.SIP("uid", LocalHelper.UserID()), Core.DB.SIP("id", survey))

In the above code the id which is the primary key is automatically generated. I want to retrieve that value to insert it on another table.

How can I retrieve the value 


Viewing all articles
Browse latest Browse all 3509

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>