Forums
This topic is locked
Insert Record then open created record
Posted 08 Aug 2004 00:37:57
1
has voted
08 Aug 2004 00:37:57 Craig McFadden posted:
Hi,I have had a look around and found solutions for access and mssql but im stuck on how to insert a record then use the inserted record id that was just created.
Im using a mysql database.
Any suggestions?
PS There will be quite a lot of updates going on on the database at the same time so the system has to be accurate. I dont think the last created record method would work.
Thanks
Replies
Replied 08 Aug 2004 18:15:35
08 Aug 2004 18:15:35 Rene Bandsma replied:
You should return the identity of the inserted record and then display that record. When a specific fieldname is NEVER the same you can also sort on that field in your folowup page in SQL.
Replied 08 Aug 2004 18:20:52
08 Aug 2004 18:20:52 Craig McFadden replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
You should return the identity of the inserted record and then display that record. When a specific fieldname is NEVER the same you can also sort on that field in your folowup page in SQL.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Thats what im looking to do just want to know how to get the identity of the newly created record
You should return the identity of the inserted record and then display that record. When a specific fieldname is NEVER the same you can also sort on that field in your folowup page in SQL.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Thats what im looking to do just want to know how to get the identity of the newly created record
Replied 08 Aug 2004 21:01:54
08 Aug 2004 21:01:54 Rene Bandsma replied:
Allright! Look at this page: www.robgt.com/tutorials/retrievenewID.asp
It shows you how to retrieve the ID after inserting with a command.
It shows you how to retrieve the ID after inserting with a command.
Replied 14 Aug 2004 01:55:50
14 Aug 2004 01:55:50 Andrew Watson replied:
why not use ado....
<pre id=code><font face=courier size=2 id=code>
set rs=server.createobject("ADODB.recordset"
rs.activeconnection = varConn
rs.source = "SELECT * FROM
rs.lockType = 3
rs.cursorLocation = 2
rs.cursorType = 1
rs.open
rs.addnew
rs("FIELD_ONE" = "VALUE A"
rs("FIELD_TWO" = "VALUE B"
rs.update
varNewID = rs("ID_FIELD"
rs.close : set rs = nothing
</font id=code></pre id=code>
:: Son, im Thirty.... ::
<pre id=code><font face=courier size=2 id=code>
set rs=server.createobject("ADODB.recordset"
rs.activeconnection = varConn
rs.source = "SELECT * FROM
rs.lockType = 3
rs.cursorLocation = 2
rs.cursorType = 1
rs.open
rs.addnew
rs("FIELD_ONE" = "VALUE A"
rs("FIELD_TWO" = "VALUE B"
rs.update
varNewID = rs("ID_FIELD"
rs.close : set rs = nothing
</font id=code></pre id=code>
:: Son, im Thirty.... ::