That is, as far as I know, a server thing. If the db you are using supports it(like MS SQL) then it should work just through the connection execute command, otherwise theres no 'safe' way of performing it.
An unsafe way(perfectly fine if the db only has one or two users, not suitable for large scale concurrant access) is to do something like the following(assuming the id is an autonumber or similar)
INSERT record
SELECT MAX(id) FROM table
and the id field will then be the last entry.