Unique id

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I am using access and I am looking for a safe reliable way to create unique
ids in a multi-user environment. Any ideas?

Thanks

Regards
 
Use MSDE? ;)
Sure you can use JET in a multiuser environment (and Mary will agree...) but
you need to be a bit more careful. Add an Identity (autoincrement) column to
the table and let JET do it for you. That's the safest way. See my article
on handling identity issues on MSDN (www.betav.com/articles.htm)

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
MVP, hRD
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.
__________________________________
 
OK, my situation is a bit complicated, I need a global unique id. One way I
can think of is to use an autonumber column and then calculate the global id
from it by adding some more characters to it. Problem is that before
inserting the record I don't know the next autonumber id that jet will
generate and I can not calculate and insert the global id at the same time.

Any ideas?

Thanks

Regards
 
I'm not sure I know what you mean by "global" unique ID (unless you mean a
GUID). If you do use a GUID, it's a 16-byte "global" identifier that your
client application creates and includes in the INSERT statement sent to
update the database.
If you can't use a GUID, you can use a strategy that's described in my book
that boils down to creating a whole set of rows ahead of time (10 or so) and
creating an updatable Recordset from those rows so you already know the
system-generated IDs. This means all changes to the rows are updates and
there are no collisions because the rows "belong" to the client. This works
best in a SQL Server... but can be encouraged to work with JET.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
MVP, hRD
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.
__________________________________
 
Hi

GUID will work for me if it can be guaranteed that each value will always be
unique. My app will be installed with several different clients, each with
several users. If each workstation can generate a unique GUID then I am
fine. I don' know if it is possible however.

Thanks

Regards
 
Yup, that's the whole idea behind a GUID. It's "guaranteed" to be unique
across systems. I understand there is a mathematical likelihood of a
duplicate number but the chances are very, very slight--something on the
order of Bush not running for President in 2004.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
MVP, hRD
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.
__________________________________
 
I would start with SQL Server books online. There are quite a few postings
on this newsgroup so poll using google... you'll find plenty of details.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
MVP, hRD
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.
__________________________________
 
Hi

Create a autonumber column, Then set the Field Size to Replication ID - This
is a GUID.

If you have many users using the same access file (or SQL database for that
matter) it is safe to use incrementing integers. The only time you really
need to use GUIDs is when you will be doing replication.


Gary
 
Back
Top