Entries for month: June 2006

Retrieve the ID of the last inserted record

This topic has come up again and I thought I would show how to do this.

1. This example will only work with MS SQL Server. You are basically running an INSERT statemenet and following it up with a SELECT statement that queries for the @@Identity.

<cfquery name="qInsertUser" datasource="myDSN">
SET NOCOUNT ON
INSERT INTO USERS (username, email)
VALUES (
   <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#usersname#">,
   <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#email#">
   )
SELECT @@Identity AS newID
SET NOCOUNT OFF
</cfquery>

<cfset newID = qInsertUser.newID>

2. This example will work with any type of database, including MS Access.

<cflock name="insertrecord" timeout="10">
<cfquery name="qInsertUser" datasource="myDSN">
INSERT INTO USERS (username, email)
VALUES (
   <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#usersname#">,
   <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#email#">
   )
</cfquery>
<cfquery name="qGetNewID" datasource="myDSN">
SELECT MAX(RecordID) AS NewID FROM USERS
</cfquery>
</cflock>

<cfset newID = qGetNewID.NewID>

No Comments

Flex 2 is here

Well Flex 2 is finally out of Beta and is Gold now! Today is a big day. Not only did the Flex 2 platform go Gold today but the Flash Player 9 was released today as well.

ColdFusion MX 7 Updater (7.0.2) was also released yesterday. This release provides developers easy integration between ColdFusion and Flex 2 applications, and also includes important fixes.

Flex 2
Flash Player 9
ColdFusion MX 7 Updater (7.0.2)

No Comments

Presentations from Adobe Developer Week

Here are the links to the Adobe Developer Week sessions that were recorded live last week:

More info can be found here!

No Comments