Get ID after insert
Hi would it be possible to have a tutorial that would show me and other people how to retrieve the last inserted id so i can redirect to the correct record based on that id the database is MySQL and im using ASP
thanks
Hi would it be possible to have a tutorial that would show me and other people how to retrieve the last inserted id so i can redirect to the correct record based on that id the database is MySQL and im using ASP
thanks
Comments
here it is
Hey
you can download the extension here:
http://www.tom-muck.com/extensions/help/insertretrieve/
I'll be making a flash tutorial for it on my website later this week.
does not work
hi i tried that extension but it does not seem to work with MySQL has anyone else got any idea's ?
did yo uever get an answer?
Get ID after insert
this works with Microsoft.Jet.OLEDB.4.0
the original dreamweaver insert code:
If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
after the MM_editCmd.Execute, insert this new code:
If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
Set rsSqlGetIdentity = Server.CreateObject("ADODB.Recordset")
SqlGetIdentity = "Select @@IDENTITY as NewID From myTable"
rsSqlGetIdentity.open SqlGetIdentity,MM_editCmd.ActiveConnection
Session("MySession") = rsSqlGetIdentity("NewID")
rsSqlGetIdentity.close
Set rsSqlGetIdentity = Nothing
MM_editCmd.ActiveConnection.Close
If (Session("MySession") <> "") Then
Response.Redirect("myPage.asp?ID="&Session("MySession"))
End If
You must me logged in to write a comment.