bjv211
asked on
Output Inserted ID in MS Access & Coldfusion
I need to output the row ID of the last inserted row without using a MAX statement. I have used the MAX statement in the past, however, it is not fool proof at accessing the correct ID. I am using CF 8 and understand that you can do this with the Result variables in cfquery however I am not able to do it using a MS access DB. Is this a limitation with using MS Access? Is there a way to do this using SQL?
<cfquery datasource="#application.dsn#" name="insertIT" result="inserted">
INSERT INTO events (title,starttime,endtime,description,contact,marketing)
VALUES ('#form.title#',<cfqueryparam cfsqltype="cf_sql_timestamp" value="#starttime2#">,<cfqueryparam cfsqltype="cf_sql_timestamp" value="#endtime2#">,'#form.description#','#form.contact#','#form.marketing#')
</cfquery>
<cfoutput>
<cfdump var="#inserted#">
</cfoutput>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What does one row of the table represent?
ASKER
Basic information (date/time,contact person,location,title) of an event. the current PK for this table is the Autonumber eventID which ties all the tables together
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
mwvisa1, thanks for your post, you gave me a good search term and I discovered this http://cfmxplus.blogspot.com/2002/08/oh-my-select-identity-works-in-access.html which seems reliable and efficient.
Very nice!
Glad you found that.
Glad you found that.
ASKER