Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 26th, 2007, 09:32 PM
Registered User
 
Join Date: Sep 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default ADD DB RECORD/ RETURN ID

Hi Everyone.

So I'm totally new to ASP, but I've done some VBS simple vbs coding and therefore I'm semi comfortable with asp. I'm currently working on a shopping cart and I'm pretty much done with the basic functionality (ie. adding products to cart, calculating coupons, removing products and updating quantities.) Pretty much what I'm currently stuck on is saving the order to an access DB and getting back the order ID, (primary key) for the new record created. How is this done?

Thanks for all the support.

 
Old October 1st, 2007, 11:55 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Assuming you are using an Autonumber field for your primary key, one easy way to do this is to use an ADODB.Recordset to add the new record instead of an insert statement. You must open a recordset (an empty recordset will do) with all the fields that are required. Add a new record and set all the required fields, and Update it. The Id field will contain the new ID.

Cheers,

Woody Z
http://www.learntoprogramnow.com
How to use a forum to help solve problems





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to return the ID through a dataset? chobo2 C# 2008 aka C# 3.0 10 June 25th, 2008 07:56 PM
Add New Record in Access DB sidra Classic ASP Databases 1 June 2nd, 2008 01:13 PM
ASP Add New Record and Get ID omninewt Classic ASP Databases 5 April 10th, 2008 12:20 PM
DTS return table ID forkhead SQL Server DTS 2 November 9th, 2006 12:15 PM
ASP program How to add new ID for new record kinshuk SQL Server ASP 3 March 21st, 2005 02:43 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.