|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Hi,
Maybe a simple question but baffling me a bit. What I am doing is spanning a form across several pages, I was going to use session variables to collect the data but there are some 23 questions which can be of various lengths in answer form so I have opted to fill in a database entry. Multiple users may be logging onto the site at any one time. What I need to do is create just one session variable - the user_ID which is allocated once the first database entries are initially added. The question: If I am doing an 'INSERT into tablename values 1, 2, 3, 4 (thus creating a new record) how can I automatically get the user_ID (which is an autonumber field in the database) straight back out and allocate it to a session variable?) - we are trying to avoid a 'login' procedure regards Maxine |
|
#2
|
||||
|
||||
|
<%
Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "[table]", DbConnStr, adOpenKeySet, adLockOptimistic, adCmdTable RS.AddNew RS("something") = Session("answer1") RS("anything") = Session("answer2") GeneratedID = RS("[Column with your AutoID]") RS.Update RS.Close SET RS = Nothing %> This should do it |
|
#3
|
|||
|
|||
|
I get the gist of that but where abouts in the above code do I specify the system DSN 'mentor' for the database table 'infograb'?
|
|
#4
|
|||
|
|||
|
Current state of events...
This is the code - the error message I get is for the line starting RS.OPEN "infograb", :
ADODB.Recordset (0x800A0BB9) Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another. <% strq1 = Request.Form("q1") strq2= Request.Form("q2") strq3 = Request.Form("q3") strq4 = Request.Form("q4") set conn = server.createobject("ADODB.Connection") Set RS = Server.CreateObject("ADODB.Recordset") conn.mode=3 conn.open "mentor" RS.Open "infograb", DbConnStr, adOpenKeySet, dLockOptimistic, adCmdTable RS.AddNew RS("mtrq1") = strq1 RS("mtrq2") = strq2 GeneratedID = RS("mtrq23") RS.Update RS.Close SET RS = Nothing conn.close set conn = nothing |
|
#5
|
|||
|
|||
|
I found it elswhere on the site - it was the adlockoptimistic that threw it all out - replacing that with a 3 (!how obvious/intuitive..) worked.
Thanks to all that have looked & though to help. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Database extract ID on Insert |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|