Link to home
Start Free TrialLog in
Avatar of ljhodgett
ljhodgett

asked on

Unique ID's in an access database using vb.net

Hi,

Like in MSSQL you can create new unique ID's using newID() is there a way to do this in an access database.

Many Thanks
Lee
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
in vba, you can use

currentdb.Execute "Alter table tableName add column newID counter"
Clarifying... If you define the field as Autonumber inside Access, any new records created through your VB.Net interface will automatically be assigned a unique number.
Avatar of ljhodgett
ljhodgett

ASKER

With Autonumber isn't this an incrementing number for the table and not for the database as in MSSQL.

Best Regards
Lee
Yes.  My understanding of the newID() function is that it will return a totally unique alpha-numeric "number", and it will never be repeated within that database (or on that computer?).    AFAIK, Access has nothing like that.  The closest is the Autonumber, which  is unique for that table.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@ ragoran:
That's a great workaround!
@mbizup:

thanks for the good word