How to retrieve last autoincremented value in MS-A

2019-01-26 19:32发布

问题:

I want to retrieve identity column value in ms access from an autoincremented column. Basically i m running a transaction in which i have to write two insert queries. 2nd query will be containing autoincremented value that was generated from query 1. how can i do that ?

回答1:

However, Microsoft Access 2000 or later does support the @@IDENTITY property to retrieve the value of an Autonumber field after an INSERT

Source: Retrieving Identity or Autonumber Values

EDIT: As noted by @David-W-Fenton, you'll also need to use Jet 4.0 OLE DB Provider (this is also described into that previous document)