Copy link to clipboard
Copied
Hi. Whenever I run this page (assuming that #FORM.EditMode# is "DeleteUser") I get
Element RECORDCOUNT is undefined in USEREDIT. |
How can I get the RecordCount for the query?
The code is:
<cfquery name="UserEdit" datasource="AITE_Test_System"> <cfif #FORM.EditMode# IS "AddUser"> INSERT INTO dbo.[#FORM.UserType#] (Fname, Lname, AD_Username) VALUES ('#FORM.Fname#', '#FORM.Lname#', '#FORM.AD_Username#') <cfelseif #FORM.EditMode# IS "DeleteUser"> DELETE FROM dbo.[#FORM.UserType#] WHERE Fname='#FORM.Fname#' AND LName='#FORM.LName#' AND AD_Username='#FORM.AD_Username#' </cfif> </cfquery>
...... NON COLDFUSION CODE HERE
<cfoutput> <cfif #FORM.EditMode# IS "DeleteUser"> <cfif NOT #UserEdit.RecordCount# GTE 0> User #FORM.Fname# #FORM.Lname# does not exist.<br /> <a href="index.cfm">Try Again</a> <cfabort> </cfif> </cfif>
</cfoutput>
Thanks!
Copy link to clipboard
Copied
To get a recordcount, run a select query.
Copy link to clipboard
Copied
For get record count of delete,
use "result" with cfquery
Copy link to clipboard
Copied
Try using this
<cfquery name="UserEdit" datasource="AITE_Test_System" result="UserEditResult">(query)
</cfquery>
#UserEditResult.RecordCount#
For more information check
http://livedocs.adobe.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=00000316.htm
Happy coding
Copy link to clipboard
Copied
Recordcount property only shows the records affected if you are using select statement. You can try the below code to get affected records on INSERT, UPDATE AND DELETE
<cfquery name="Test" datasource="test">
SET NOCOUNT ON
Delete from testTable WHERE firstname= 'Harpal'
SELECT deletecount=@@ROWCOUNT
SET NOCOUNT OFF
</cfquery>
<cfoutput>
recordcount:=#Test.deletecount#
</cfoutput>