I am doing a data insert into an MS Access 2000 DB and I need to get the id of the new record that was just inserted. but I don't want to go through the hassle of querying the DB for it.
I found a reference or two out on the web that indicates that something like this should work:
<cfquery datasource="#mydsn#" name="myquery">
insert into table (field1,field2)
values ('#value1#','#value2#');
select @@IDENTITY as 'latestid'
</cfquery>
But, when I have the semi-colon in there I get an error about extra characters at the end of the SQL statement. If I remove it, the system tells me that it needs a semi-colon.
Now - to be honest, I'm not really sure if I have an IDENTITY field in my DB. I can't find anything on how their created and I assume that this is the primary key field (normally ID).
So...if anyone could help me out, that would be greatly appreciated!
I found a reference or two out on the web that indicates that something like this should work:
<cfquery datasource="#mydsn#" name="myquery">
insert into table (field1,field2)
values ('#value1#','#value2#');
select @@IDENTITY as 'latestid'
</cfquery>
But, when I have the semi-colon in there I get an error about extra characters at the end of the SQL statement. If I remove it, the system tells me that it needs a semi-colon.
Now - to be honest, I'm not really sure if I have an IDENTITY field in my DB. I can't find anything on how their created and I assume that this is the primary key field (normally ID).
So...if anyone could help me out, that would be greatly appreciated!