Get ready for BLACK FRIDAY shopping starting in

Forums

This topic is locked

Passing the newly created ID after insert

Posted 02 Aug 2002 17:18:27
1
has voted
02 Aug 2002 17:18:27 Zain Magsi posted:
Hi,

What is the best way to pass the newly created id of recordset to the next page?

Thanks

Zain Magsi

Replies

Replied 02 Aug 2002 19:29:59
02 Aug 2002 19:29:59 aegis kleais replied:
On the page that needs the newly created ID make a recordset for the table that the ID is a part of and make the order and sort:

SELECT ID from tblTest ORDER BY ID DESC

If the ID is an autonumber it will continually get higher as new records are added. If you return descendingly, that should return the last one that was just made (ie, the one from previous page)

Aegis Kleais
New Media Web Developer
(DWMX : IIS5.1 : SQL2K : WXP : ASP[VB/JS])
Replied 03 Aug 2002 03:23:21
03 Aug 2002 03:23:21 Owen Eastwick replied:
I don't like to crtisize other peoples posts but "SELECT ID from tblTest ORDER BY ID DESC" is not a safe method of retrieving the correct Record ID

This is fine if only one person is performing the Insert at a time, but if two people INSERT a record concurrently the one of the users is going to get the other users ID because this was the last record ID, but it's not their record ID.

This is easy to sort in SQL Server, but a bit more tricky with an Access database, in any case you can find a link to the SQL Server solution and see my work around for Access here:
www.udzone.com/forum/topic.asp?TOPIC_ID=17360&FORUM_ID=3&CAT_ID=2&Topic_Title=Insert+Record+%28+simple+I%27m+Sure+%29&Forum_Title=Dreamweaver+UltraDev

Regards

Owen.

Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo

Edited by - oeastwick on 03 Aug 2002 05:31:12
Replied 03 Aug 2002 03:46:00
03 Aug 2002 03:46:00 aegis kleais replied:
You know, when I made my post, I was thinking only in the mindset that he's creating a system that will be for his use only. It's best that you do question it. I have this problem of thinking in a one track method. I've been doing nothing but making backend websites left and right lately, so I didn't take this from a public point of view.

Aegis Kleais
New Media Web Developer
(DWMX : IIS5.1 : SQL2K : WXP : ASP[VB/JS])

Reply to this topic