p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

proasp_howto thread: Getting an AutoNumber value after a SQL INSERT INTO


Message #1 by "Peter Foti (PeterF)" <PeterF@S...> on Wed, 21 Mar 2001 12:43:07 -0500
Always thought it did'nt work with access databases, there's a lot to learn.
Thanks Ken.

Regards,

Gerhard Wentink

----- Original Message -----
From: "Ken Schaefer" <ken@a...>
To: "How To" <proasp_howto@p...>
Sent: Friday, March 23, 2001 1:22 AM
Subject: Re: Getting an AutoNumber value after a SQL INSERT INTO


>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> : Assuming that you use a access database:
> : Instead of using an INSERT, create a recordset , use the addnew method
and
> : the update method. Then the recordpointer is on the newly inserted
record.
> : Then you can assign the autonumber to a variable. Something like:
> : lngCID=objRS("CID").
> : This variable can be used in an INSERT on the second table
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Slightly faster way would be to use the Jet.OLEDB.4.0 provider and
> @@Identity
>
> http://www.adOpenStatic.com/faq/fastestautonumber.asp
>
> Cheers
> Ken


  Return to Index