ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingASP Development

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 ASP Free Forums Sponsor:
  #1  
Old April 21st, 2000, 07:51 PM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 22
How to get the NUMID (primary key) of a new record ?

<i><b>Originally posted by : ALJ (alj@leaweb.org)</b></i><br />I have a DB with a field (NUMID) (autonumber primary key)<br /><br />I add a record in my recordset.<br /><br />How can I get the NUMID of this record ?<br /><br />Thank's<br />ALJ<br />

Reply With Quote
  #2  
Old April 23rd, 2000, 03:16 AM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 22
<i><b>Originally posted by : Dave Z (dz@dzigns.com)</b></i><br />Personally, I prefer an SQL SELECT statement using some of the other information from the form for assurance but...(and I am not sure of the typical ADO stuff)<br />'connect...<br />'Open a table<br />Set rs = Server.CreateObject("ADODB.Recordset")<br />'and<br />rs.movelast<br />'will get you the last record entered<br /><br /><br />------------<br />ALJ at 4/21/2000 5:51:43 PM<br /><br />I have a DB with a field (NUMID) (autonumber primary key)<br /><br />I add a record in my recordset.<br /><br />How can I get the NUMID of this record ?<br /><br />Thank's<br />ALJ<br />

Reply With Quote
  #3  
Old May 1st, 2000, 04:55 AM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 22
<i><b>Originally posted by : AndrewJ (andrewjens@hotmail.com)</b></i><br />rs.movelast will not be reliable in a multiuser environment - someone else may add a record between the time you added and movelast. This is an age-old db problem with only two real solutions:<br />1) as Dave Z suggests - SELECT on a secondary key to find the record just created, or<br />2) Get the ID of the record you want to add before you add it. This is the preferred solution in multiuser databases (however you cannot use an autonumber ID field). The steps are:<br />-start a transaction<br />-lock and get the next ID from an independent lookup table<br />-increment the next ID in the lookup table. unlock<br />-add the record with the new ID<br />-commit the transaction<br />Of course, the ID of the new record is stored in a variable and you can do what you like.<br />Cheers<br /><br />------------<br />Dave Z at 4/23/2000 1:16:04 AM<br /><br />Personally, I prefer an SQL SELECT statement using some of the other information from the form for assurance but...(and I am not sure of the typical ADO stuff)<br />'connect...<br />'Open a table<br />Set rs = Server.CreateObject("ADODB.Recordset")<br />'and<br />rs.movelast<br />'will get you the last record entered<br /><br /><br />------------<br />ALJ at 4/21/2000 5:51:43 PM<br /><br />I have a DB with a field (NUMID) (autonumber primary key)<br /><br />I add a record in my recordset.<br /><br />How can I get the NUMID of this record ?<br /><br />Thank's<br />ALJ<br />

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingASP Development > How to get the NUMID (primary key) of a new record ?


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