Board index » delphi » Retrieving an autoincrement id number after posting a new record

Retrieving an autoincrement id number after posting a new record

Hi,

This is probably an old one for some of you. I'm using Delphi 5 Professional
and Access 2002.

How do I, after posting a record using a TTable, get the id number which is
assigned to the record as an autoincrement number?

Thanks,
Stephen

 

Re:Retrieving an autoincrement id number after posting a new record


Quote
Stevio wrote:
> Hi,

> This is probably an old one for some of you. I'm using Delphi 5 Professional
> and Access 2002.

> How do I, after posting a record using a TTable, get the id number which is
> assigned to the record as an autoincrement number?

> Thanks,
> Stephen

Just read the auotinc field after the post. This works on MS SQL server
using ADO.

DataSet.FieldValues['autoincfield'] := NULL;
DataSet.Post;
value := DataSet.FieldValues['autoincfield'];  // Get the value.

/Thomas

Other Threads