Link to home
Start Free TrialLog in
Avatar of u7c76
u7c76

asked on

Accessing MS Access through VB.NET

I'm currently developing a VB.net win forms application.  This application uses MS Access 2000 for the database.  When inserting into a table, the primary key is an autonumber. Then I need to insert this autonumber into this other table.  This autonumber is a foriegn key in this other table.  Is there an easy way to get what the value of the autonumber of the table at the time of insert, or do I need to write a query to retrieve this value.

Thanks,
Brian
Avatar of YZlat
YZlat
Flag of United States of America image

use @@identity
also you could use

SELECT Max(RecordID) as LastAutoID FROM Table1

to get the last ID inserted. But if you are using Access 200 or higher, I recomment using @@IDENTITY
ASKER CERTIFIED SOLUTION
Avatar of YZlat
YZlat
Flag of United States of America 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