Re: Access Autonumber problem
- From: "William \(Bill\) Vaughn" <billva@xxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 8 Oct 2006 17:01:45 -0700
If you insist on using Access, you'll find that JET engine's inability to
execute more than one operation at a time forces you to either fetch the
@@Identity value post INSERT or use another scheme. I've been writing a lot
about identity issues lately so check the archives of this list. I expect
that a better alternative would be to use a GUID as the row identifier. This
is also supported in Oracle (and SQL Server). In this case your application
simply generates a GUID in code and uses that as the PK in place of an
engine-generated identity value.
hth
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
Between now and Nov. 6th 2006 you can sign up for a substantial discount.
Look for the "Early Bird" discount checkbox on the registration form...
-----------------------------------------------------------------------------------------------------------------------
Microsoft MVP, Author, Mentor
Microsoft MVP
"dcali001" <dcali001@xxxxxxxxxxxxxxxx> wrote in message
news:2C933C31-415E-4F0B-BE34-E66091C4B42C@xxxxxxxxxxxxxxxx
I would use SQLServer Express if I could, but unfortunatly this is not the
primary application that the database uses. I am actually writing web
services to expose functionality for a VB6 application that already has a
fairly large customer base. We use Oracle for our larger customers and
Access for the smaller ones.
In traditional ADO, we would use something similar to the following:
---
rs!ID = CLng(Rnd() * -10000000)
rs.Update
rs.Resync adAffectCurrent, adResyncAllValues
rs!ID = rs!CounterID & Format(StoreInfo.StoreNum, "00")
---
I hate to believe that this is impossible in ADO.NET.
Dave
"Cor Ligthert [MVP]" wrote:
Dcali,
In fact everything, you get only back the latest ID. In SQLServer the ID
is
giving back automaticly in Access not. Therefore in my idea is eithter to
change to SQLServer (Express) or to refresh everytime your dataset
completely.
Although you have first to do an update of the dataset of course and can
than try to get the id, will the ident that you only be the latest, not
all
the ones that are new in the same dataset.
While the event that you are using is typical in a binding situation,
where
the datarow is updated from a binded control, it is than of course still
not
in the database.
Does not help much, but I hope a little bit.
Cor
.
- Follow-Ups:
- Re: Access Autonumber problem
- From: Kevin Yu [MSFT]
- Re: Access Autonumber problem
- References:
- Re: Access Autonumber problem
- From: Cor Ligthert [MVP]
- Re: Access Autonumber problem
- Prev by Date: Re: Parameter markers and formats
- Next by Date: Re: SqlBulCopy and sql server 2005 crash
- Previous by thread: Re: Access Autonumber problem
- Next by thread: Re: Access Autonumber problem
- Index(es):
Relevant Pages
|