ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old July 8th, 2003, 03:29 AM
snorkmaiden snorkmaiden is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 11 snorkmaiden User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Talking Database extract ID on Insert

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

Reply With Quote
  #2  
Old July 8th, 2003, 05:22 AM
Tim_Lensen's Avatar
Tim_Lensen Tim_Lensen is offline
Wonder of the world
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: the Netherlands
Posts: 22 Tim_Lensen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
<%
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

Reply With Quote
  #3  
Old July 8th, 2003, 06:30 AM
snorkmaiden snorkmaiden is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 11 snorkmaiden User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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'?

Reply With Quote
  #4  
Old July 8th, 2003, 07:23 AM
snorkmaiden snorkmaiden is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 11 snorkmaiden User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #5  
Old July 8th, 2003, 08:13 AM
snorkmaiden snorkmaiden is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 11 snorkmaiden User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Database extract ID on Insert


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway