Here's a way to create a Session ID from a newly inserted record from a database.
**********************************************
[color green]'Immediatelly after your insert statement be sure to comment out the following statements:
[ul][li][color green]' MM_editCmd.ActiveConnection.Close[/color]
[/li] [li][color green]'Response.Redirect(MM_editRedirectUrl)[/color]
[/li][/ul]
as shown below and adding [color blue]the script in blue[/color]
[/color]
If (Not MM_abortEdit) Then
[color green]' execute the insert[/color]
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
[color green]' MM_editCmd.ActiveConnection.Close[/color]
If (MM_editRedirectUrl <> "") Then
[color green]'Response.Redirect(MM_editRedirectUrl)[/color]
End If
End If
End If
%>
[color blue]<%
If (CStr(Request("MM_insert")) <> "") Then
set TonyRS = Server.CreateObject("ADODB.Recordset")
TonyRS.ActiveConnection = MM_editCmd.ActiveConnection
TonyRS.Source = "SELECT max(id) as MaxID FROM YOUR_TABLE"
TonyRS.CursorType = 0
TonyRS.CursorLocation = 2
TonyRS.LockType = 3
TonyRS.Open()
Session("NewID")=TonyRS("MaxID")
Response.Redirect(MM_editRedirectUrl)
end if
%>
[/color]
**********************************************
As you can see, I'm selecting the MAX (id) from the database and creating a session("NewID") that you can call from anywhere you need to.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.