Skip to main content
July 7, 2009
Question

SQL Delete RecordCount

  • July 7, 2009
  • 4 replies
  • 2509 views

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!

    This topic has been closed for replies.

    4 replies

    Participating Frequently
    July 8, 2009

    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>

    Participating Frequently
    July 8, 2009
    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


    Dileep_NR
    Inspiring
    July 8, 2009

    For get record count of delete,

    use "result" with cfquery

    Inspiring
    July 8, 2009

    To get a recordcount, run a select query.