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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

view the latest inserted record

Status
Not open for further replies.

kindicheema

Programmer
Jun 21, 2006
6
GB
Hi

Using vb with asp.net, I have inserted a record using the formview control, and after insertion i wish to view that inserted record in the itemsview page, insted of being directed to last record i was viewing before clicking add.

Thanks

 
You'll have to post some code so we know what you are trying to do.
 
2 ways you could do this, (1) is the get the max(id) row from the db, (2) or you're stored procedure that adds the new record could return @@identity, you can then do a get from that returned id (this is preferred).

 
I believe SCOPE_IDENTITY() is a lot safer than @@Identity.

My understanding is that @@Identity will get the last auto number inserted into the database by any user whilst SCOPE_INDENTITY() will get the one for the record you just inserted within the current stored procedure.

Feel free to correct me if I got this wrong but that's my understanding.

Smeat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top