There is a command: SELECT @@IDentity
Put this in the same AdoQuery component with the insert command. Call Open instead of ExecSql to retreive the data. It will return the Identity field for the record just added. i.e.
In the AdoQuery.Sql property enter
INSERT INTO TestTable (field1, Field2)
Values('Test1','Test2')
Select @@Identity as AutoIncFieldName
Then in the code call Open or Active := TRUE. This should give you the value of the identity.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.