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

Retriving Insert Info AFTER Insert Operation

Status
Not open for further replies.

Annelies

Programmer
Joined
Nov 25, 2001
Messages
72
I have a simple insert page, which is working fine, which inserts some data into the database. Upon insertion into the DB, a unique identifier is created and inserted (by the DB) for that record.

Does anyone know how to easily retrieve the unique identifier created upon the insert (in this case, called Contact_ID). I need the Contact_ID to use on the next page.

Is it a matter of simply moving to the last record in the table and using that Contact_ID, or is there a way of easily retrieving this information.

Many thanks!

Annelies
 
If it's a simple recall of the most recent record (and that is always the case) then you could just bind the data for that recordset onto the next page and make sure that you sort according to your unique identifier in descending order. This will list the most recently created record first. I use this method to offer folk a preview facility for files they may have just uploaded or created. This'll work nicely if you don't have several dozen folk all creating files at once. The safest option in this case possibly be to generate some session variables and pass them along into the new page as hidden form fields assuming you're using a form to pass in info over in this case it would be request.form type if you're not using a form then pass them through as request.querystring variables (I'm sure someone'll correct me if Ive mixed me variables up ! ;))
There's a good tutorial somewhere on the web, I'll dig it out and post it later.

Have fun

M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top