SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL 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 May 24th, 2002, 09: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
How to get the primary key value from a just new created record ?

<i><b>Originally posted by : Pascal (pascal.comminot@edu.ge.ch)</b></i><br />Hi<br /><br />I want to get the primary key value (autoincremented value) of a just new created record. But I got nothing with everything I tried.<br /><br />Lets take the following Table in my database<br /><br />id, primary key, autoincremented longint<br />somefield, text<br /><br />ConnectionStr = "DSN=somedatabase"<br />Set RS= Server.CreateObject("ADODB.RecordSet")<br /><br />RS.Open "MyTable", ConnectionStr, adLockOptimistic, adCmdTable<br /><br />RS.AddNew<br />RS("SomeField") = "Some value"<br />id1 = RS("ID")<br />RS.Update<br /><br />id2 = RS("ID")<br /><br />--> both id1 and id2 remain empty in my ASP code.<br />but If I look in the database, the record has been registered, and the if field contains a unique value.<br />

Reply With Quote
  #2  
Old October 28th, 2002, 08:14 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 : kalicharan (boorugu_kali@yahoo.com)</b></i><br /><br />Hello Friend,<br />I tried it once in my programming and got it.<br />I think u should get the value before assigning some value try it. In Access database I got this value.<br /><br />RS.AddNew<br />id1 = RS("ID")<br />RS("SomeField") = "Some value"<br />RS.Update<br /><br />Try out with this<br /><br /><br /><br /><br />------------<br />Pascal at 5/24/2002 6:55:32 AM<br /><br />Hi<br /><br />I want to get the primary key value (autoincremented value) of a just new created record. But I got nothing with everything I tried.<br /><br />Lets take the following Table in my database<br /><br />id, primary key, autoincremented longint<br />somefield, text<br /><br />ConnectionStr = "DSN=somedatabase"<br />Set RS= Server.CreateObject("ADODB.RecordSet")<br /><br />RS.Open "MyTable", ConnectionStr, adLockOptimistic, adCmdTable<br /><br />RS.AddNew<br />RS("SomeField") = "Some value"<br />id1 = RS("ID")<br />RS.Update<br /><br />id2 = RS("ID")<br /><br />--> both id1 and id2 remain empty in my ASP code.<br />but If I look in the database, the record has been registered, and the if field contains a unique value.<br />

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > How to get the primary key value from a just new created 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 4 hosted by Hostway
Stay green...Green IT