If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Problem with DB update, then retrieving an ID

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-03-04, 10:57
Skatalite Skatalite is offline
Registered User
 
Join Date: Sep 2004
Posts: 1
Problem with DB update, then retrieving an ID

I want to be able to insert a new record into the database, then retrieve the ID of that record, which is an identity field. My problem is that when I attempt to retrieve the ID, nothing comes back.
Here is a sample of my code:

DBConnect 1,"*","tblDocuments","DocumentID=0",1
oRS(1).AddNew
oRS(1)("DocumentName")=ContractName
oRS(1)("DocumentDate")=ContractDate
oRS(1)("ProjectID")=ProjectID
oRS(1)("DocumentTypeID")=2
oRS(1).Update
ContractID=oRS(1)("DocumentID")
ContractFileName="ContractID"&ContractID&"."&FileE xtension
Hence, the ContractFileName comes back as ContractID.doc...or whatever the extension is. The ID is not returned for some reason.
Reply With Quote
  #2 (permalink)  
Old 09-04-04, 20:21
Seppuku Seppuku is offline
Useless...
 
Join Date: Jul 2003
Location: SoCal
Posts: 721
Are you using MS Access, MS SQL Server, or some other DB Server?
__________________
That which does not kill me postpones the inevitable.
Reply With Quote
  #3 (permalink)  
Old 09-04-04, 21:28
sundialsvcs sundialsvcs is offline
Registered User
 
Join Date: Oct 2003
Posts: 706
This is, unfortunately, definitely something that will be "DB-specific." Some engines force you to requery; some provide a way to retrieve the ID-number that was assigned.

It is for this very reason that many applications use logic that allows the client to obtain an ID-number from a pool or generator, so that server-assigned numbers are never used. It's always been a "crufty" part of application design: one in which all of the so-called solutions taste bad.
__________________
ChimneySweep(R): fast, automatic
table repair at a click of the
mouse! http://www.sundialservices.com
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On