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!

response.write to display record id after form updates sql

Status
Not open for further replies.

melrse

Programmer
Dec 13, 2000
25
US
Hi. Have had much success with obtaining help and am muddled.
I have a form updating a sql db which works fine. After the form updates the db and the connection for that single update is complete before closing, I want to display what the associated recordID for that form is back.

Have a book and see the response.write.

Also see sqldatareader. Do I need to do this when I already have the record opened for insert?

I just want to obtain after the submit button is pressed, what the recordID is for that single updated record.

Please direct me. Seems like this should be easy but obviously its not or its me.
Thanks...

 
I'm not sure if this is the best way... but it is a way.


Basically you will have to create a Stored Procedure for your insert that returns the RecordID from the insert. Then you query the DB for your new record using the returned record ID. After the insert and query you can then close your connection.


Senior Software Developer
 
If you are updating a record, you would already have the record id in your DataTable or should be pulling it down into a variable if using a DataReader. If you are inserting a record, you want to use a ;SELECT SCOPE_IDENTITY() at the end of your INSERT statement. This will give you the unique identifier of the record which you just inserted.
 
SELECT SCOPE_IDENTITY()


That was what I couldn't remember! I knew there was a better way then to select the greatest id, but I couldn't remember the SQL Function at the time. Thanks for posting that.

Senior Software Developer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top