How to get the autoincrement value with Access db

  • Thread starter Thread starter RA
  • Start date Start date
R

RA

Hi

I have two tables and one has a relationship to the first table primary key
which is an autoincrement field. So After I add a record to the table 1 I
need to get this autoincrement field so I can add it to table two. How can I
do this? I am using access database. Is there a way to do it also with
dataset?


Thanks
 
Hi,

One way to do this is to use "SELECT @@Identity FROM <tablename>". This will
return you the last inserted id in the table specified.

I hope this helps.
----------------------
 
Hi,

Read the article
Retrieving Identity or Autonumber Values
in .net help files.
 
Back
Top