Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

SQL Delete RecordCount

Guest
Jul 07, 2009 Jul 07, 2009

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!

2.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 07, 2009 Jul 07, 2009

To get a recordcount, run a select query.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 07, 2009 Jul 07, 2009

For get record count of delete,

use "result" with cfquery

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 08, 2009 Jul 08, 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


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 08, 2009 Jul 08, 2009
LATEST

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>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources