Re: Retrieving Auto increment field
- From: "David Lloyd" <David@xxxxxxxxxxxxxxxx>
- Date: Fri, 11 Nov 2005 08:51:02 -0500
Derek:
The following KB article shows how to use the an @@Identity SELECT query to
retrieve the autoincrement value. If you are using version 4.0 of the JET
OLEDB provider then you can consider this as a possible alternative. Since
the value returned is connection specific, you should get the desired
results in a multi-user environment.
http://support.microsoft.com/default.aspx?scid=kb;en-us;232144
--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com
This response is supplied "as is" without any representations or warranties.
"Derek" <Derek@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1C6D65D1-1B57-4967-9A3B-2F18D12E5004@xxxxxxxxxxxxxxxx
I am entering information into two tables (Sales and Forecasts). The Sales
table has an autoincrement field (RecordID). RecordID is then used as a
Foreign key in the second table (where it is a normal long).
I am using excel as a front end, and ADO to connect to the database. My
code currently works as follows.
1) Insert into the Sales table.
2) Query the Sales table to get the RecordID.
3) Insert into the Forecasts table.
The problem I'm having is that step 2 is often failing. It appears that the
information hasn't been "fully" inserted into Access, and therefore the
query
returns no records.
I would prefer not to get the number manually, as it is possible that two
users will be inserting at the same time, and I'm worried the numbers will
get confused.
How do I get the autoincrement number successfully?
Thanks
Derek
.
- Prev by Date: Re: Running custom Excel query for Access
- Next by Date: Re: Running custom Excel query for Access
- Previous by thread: Select Query "Where" Problem
- Next by thread: Re: date / text criteria for query
- Index(es):
Relevant Pages
|