User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ColdFusion section within the Web Development category of DaniWeb, a massive community of 332,688 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,423 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ColdFusion advertiser:

<cfquery> Undefined

Join Date: Feb 2008
Posts: 32
Reputation: cmhampton is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 3
cmhampton cmhampton is offline Offline
Light Poster

Re: <cfquery> Undefined

  #2  
Mar 28th, 2008
First of all, please don't name your query cool.recordCount. RecordCount is a property of the query object. Name it something like qryCool.

Secondly, you're missing a </cfif> tag. You have two cfif statements, but only one closing.

Do you already have code that determines if this is a duplicate record? What is the 'cool' variable for? If you already check, try this code and let me know:

  1. <cfif cool EQ 0>
  2. <cfquery name="qryCool" datasource="#Request.proto#">
  3. INSERT INTO proton(
  4. name,
  5. moon
  6. )
  7. VALUES(
  8. '#Trim(Form.name)#',
  9. '#Trim(Form.moon)#'
  10. )
  11. </cfquery>
  12. <cfelse>
  13. This Record Already Exists
  14. <cfinclude template="adduser.cfm">
  15. </cfif>

Change the adduser.cfm to include it's own <cfquery> tag.

Alternately, you can do it all in SQL if you haven't determined whether this is a duplicate record or not.

  1.  
  2. <cfquery name="qryCool" datasource="#Request.proto#">
  3. IF NOT EXISTS
  4. (
  5. SELECT
  6. name,
  7. moon
  8. FROM
  9. proton
  10. WHERE
  11. name = '#Trim(Form.name)#'
  12. AND moon = '#Trim(Form.moon)#'
  13. )
  14. BEGIN
  15. INSERT INTO proton(
  16. name,
  17. moon
  18. )
  19. VALUES(
  20. '#Trim(Form.name)#',
  21. '#Trim(Form.moon)#'
  22. )
  23.  
  24. SELECT SCOPE_IDENTITY() AS RecordID
  25.  
  26. END
  27.  
  28. ELSE
  29. SELECT NULL AS RecordID
  30. </cfquery>
  31.  
  32. <cfif qryCool.RecordID EQ "">
  33. This Record Already Exists
  34. <cfelse>
  35. <!--- Do something here --->
  36. </cfif>
Reply With Quote  
All times are GMT -4. The time now is 4:53 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC