troubleshooting Question

query to pull results from my Access database

Avatar of joaquinch
joaquinch asked on
Web Servers
2 Comments1 Solution202 ViewsLast Modified:
I`m doing a query to my dsn "salamanca7" and dont work: The debuggin says
 The error occurred in C:\CFusionMX7\wwwroot\salamanca7.com\formdbs\resultados1.cfm: line 4

2 : SELECT *
3 : FROM peticiones
4 : WHERE #PreserveSingleQuotes(WhereClause)#

<----so this is the error #PreserveSingleQuotes(WhereClause)#--->
--------------------------------------------------------------------------------------------------------
Here is the code I used

<cfquery name="Resultados" datasource="salamanca7">
SELECT *
FROM peticiones
WHERE #PreserveSingleQuotes(WhereClause)#

<cfparam name="form.nombre" default="">
<cfif #form.nombre# is not '' >
AND nombre LIKE '%#form.nombre#%'
</cfif>

<cfparam default="" name="form.apellidos">
<cfif #form.apellidos# is not '' >
AND apellidos LIKE '%#form.apellidos#%'
</cfif>
<cfparam name="form.day" default="">
<cfif #form.day# is not '' >
AND day = '#form.day#'
</cfif>
<cfparam name="form.month" default="">
<cfif #form.month# is not '' >
AND month = '#form.month#'
</cfif>
<cfparam name="form.year" default="">
<cfif #form.year# is not '' >
AND year = '#form.year#'
</cfif>
<cfparam name="form.direccion" default="">
<cfif #form.direccion# is not ''>
AND direccionlocation LIKE '%#form.direccion#%'
</cfif>
<cfparam name="form.pais" default="">
<cfif #form.pais# is not ''>
AND paislocation LIKE '%#form.pais#%'
</cfif>
<cfparam name="form.email" default="">
<cfif #form.email# is not ''>
AND email LIKE '%#form.email#%'  
</cfif>
<cfparam name="form.comentarios" default="">
<cfif #form.comentarios# is not ''>
AND comentarios LIKE '%#form.comentarios#%'
</cfif>
<cfparam name="form.language" default="">
<cfif #form.language# is not ''>
AND languagelocation LIKE '#form.language#'
</cfif>
<cfparam name="form.recipient" default="joaquin@seville.org">
<cfif #form.recipient# is not ''>
AND recipient LIKE '#form.recipient#'
</cfif>
<cfparam name="form.thankurl" default="http://www.alhambra-instituto.org/thankyou.htm">
<cfif #form.thankurl# is not ''>
AND thankurl LIKE '%#form.thankurl#%'
</cfif>
<cfparam name="form.country" default="">
<cfif #form.country# is not ''>
AND countrylocation LIKE '#form.country#'
</cfif>
<cfparam name="form.description" default="">
<cfif #form.description# is not ''>
AND description LIKE '%#form.description#%'
</cfif>
<cfparam name="form.keywords" default="">
<cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
<cfparam name="PageNum_Resultados" default="1">
<cfif #form.keywords# is not ''>
AND keywords LIKE '%#form.keywords#%'
</cfif>
ORDER BY day DESC
</cfquery>
<cfset MaxRows_Resultados=25>
<cfset StartRow_Resultados=Min((PageNum_Resultados-1)*MaxRows_Resultados+1,Max(Resultados.RecordCount,1))>
<cfset EndRow_Resultados=Min(StartRow_Resultados+MaxRows_Resultados-1,Resultados.RecordCount)>
<cfset TotalPages_Resultados=Ceiling(Resultados.RecordCount/MaxRows_Resultados)>

<CFSET RecordsPerPage = 25>
<CFPARAM NAME = "StartRow" DEFAULT = "1">
<CFSET EndRow = StartRow + RecordsPerPage - 1>
<CFIF EndRow GTE Resultados.RecordCount>
     <CFSET EndRow = Resultados.RecordCount>
     <CFSET Next = false>
<CFELSE>
     <CFSET Next = true>
     <CFIF EndRow + RecordsPerPage GT Resultados.RecordCount>
          <CFSET NextNum = Resultados.RecordCount - EndRow>
     <CFELSE>
          <CFSET NextNum =  RecordsPerPage>
  </CFIF>
     <CFSET NextStart = EndRow + 1>
</CFIF>
<CFIF StartRow IS 1>
     <CFSET Previous = false>
<CFELSE>
     <CFSET Previous = true>
     <CFSET PreviousStart = StartRow - RecordsPerPage>
</CFIF>

<CFSET NumPages = Ceiling(Resultados.RecordCount / RecordsPerPage)>
<CFPARAM NAME = "PageNum" DEFAULT = "1">
<p>
<CFOUTPUT>Now displaying records #StartRow# to #EndRow# of #Resultados.RecordCount#.
  <P>
</CFOUTPUT>
<!---HERE YOU OUTPUT YOUR QUERY RESULTS
THIS FORM OF PAGING IS PRETTY BASIC SO IT'S EASY TO CUSTOMIZE
YOU CAN ADD A TABLE HERE AS WELL JUST PUT YOUR TABLE TAG OUTSIDE
THE QUERY OUTPUT AND TR'S INSIDE TO LIST THE ROWS, I'M SURE YOU KNOW THOUGH--->


</p>
<table border="1">
  <tr>
    <td>ID</td>
    <td>fecha</td>
    <td>hora</td>
    <td>nombre</td>
    <td>apellidos</td>
    <td>email</td>
    <td>pais</td>
    <td>dia</td>
    <td>direccion</td>
    <td>language</td>
    <td>comments</td>
    <td>mes</td>
    <td>ano</td>
    <td>ciudad</td>
    <td>aux1</td>
    <td>aux2</td>
    <td>origen</td>
  </tr>
  <cfoutput query="Resultados" startRow="#StartRow_Resultados#" maxRows="#MaxRows_Resultados#">#currentrow#
    <tr>
      <td>#Resultados.ID#</td>
      <td>#Resultados.fecha#</td>
      <td>#Resultados.hora#</td>
      <td>#Resultados.nombre#</td>
      <td>#Resultados.apellidos#</td>
      <td>#Resultados.email#</td>
      <td>#Resultados.pais#</td>
      <td>#Resultados.dia#</td>
      <td>#Resultados.direccion#</td>
      <td>#Resultados.language#</td>
      <td>#Resultados.comments#</td>
      <td>#Resultados.mes#</td>
      <td>#Resultados.ano#</td>
      <td>#Resultados.ciudad#</td>
      <td>#Resultados.aux1#</td>
      <td>#Resultados.aux2#</td>
      <td>#Resultados.origen#</td>
    </tr>
  </cfoutput>
</table>
<!---END OF OUTPUT--->
<TABLE BORDER="0">
     <TR>
          <TD VALIGN = "top">
               <CFIF Previous>
                    <CFOUTPUT>
                         <A HREF = "CFPreviousNext.cfm?StartRow=#PreviousStart#&PageNum=#DecrementValue(PageNum)#"><< Previous</A>
                    </CFOUTPUT>
               <CFELSE>
               </CFIF>
          </TD>
          <TD VALIGN = "top">
               <CFIF Next>
                    <CFOUTPUT>
                         <A HREF = "CFPreviousNext.cfm?StartRow=#NextStart#&PageNum=#IncrementValue(PageNum)#">Next >></A>
                    </CFOUTPUT>
               <CFELSE>
               </CFIF>
          </TD>
     </TR>
</table>


Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros