How to get the autoincrement value with Access db

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
 
G

Guest

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.
----------------------
 
M

Miha Markic [MVP C#]

Hi,

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top