Thanks Tim...
I am using SQL Server.
Now how do I reference MyID outside the cfquery?
This isn't working..
<cfquery name="InsertType" datasource="resDB">
Insert Into TYPE
(
TypeName,
TypeDesc
)
Values
(
'#form.TypeName#',
'#form.TypeDesc#'
)
select @@identity as myID
from type
</cfquery>
<cfset lastID = InsertType.myID>
<cfquery name="getLast" datasource="resDB">
SELECT TYPE.typeID, TYPE.typeName, TYPE.typeDesc FROM TYPE
Where TypeID = #lastID#
</cfquery>
It's saying Element MYID is undefined in INSERTTYPE. Thanks for all
your help :)
Candace K. Cottrell, Web Developer
The Children's Medical Center
One Children's Plaza
Dayton, OH 45404
937-641-4293
http://www.childrensdayton.org
[EMAIL PROTECTED]
>>> [EMAIL PROTECTED] 3/20/2003 3:28:13 PM >>>
Is it SQL Server?
use @@identity to get the max id in SQL Server so something like:
<cfquery name="InsertType" datasource="resDB">
Insert Into TYPE
(
TypeName,
TypeDesc
)
Values
(
'#form.TypeName#',
'#form.TypeDesc#'
)
select @@identity as myID
from type
</cfquery>
-----Original Message-----
From: Candace Cottrell [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 20, 2003 3:01 PM
To: CF-Community
Subject: Referencing my last record
Is there any way to reference the ID of the last record I added?
<cfquery name="InsertType" datasource="resDB">
Insert Into TYPE
(TypeName, TypeDesc)
Values ('#form.TypeName#', '#form.TypeDesc#')
</cfquery>
Something like:
<cfset lastID = InsertType.TypeID>
TypeID is an identity field in MSSQL.
Candace K. Cottrell, Web Developer
The Children's Medical Center
One Children's Plaza
Dayton, OH 45404
937-641-4293
http://www.childrensdayton.org
[EMAIL PROTECTED]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=5
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=5
This list and all House of Fusion resources hosted by CFHosting.com. The place for
dependable ColdFusion Hosting.
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.5