954,164 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

dynamic Query

I have a SQL Query build as a string but i cant seem to pass it into to the

But it does not work

any one can help me?

<cfif ISDEFINED ('member')>
<CFSET SQL = "SELECT *
FROM precontract ">
<CFSET SQL_Coubr = 0 >
<cfif form.member neq "">
<cfif SQL_Coubr eq 0>
<CFSET SQL = SQL& " WHERE " >
<cfelse>
<CFSET SQL = SQL& " OR " >
</cfif>
<CFSET SQL = SQL& " name LIKE '%#form.member#%' " >
<CFSET SQL_Coubr = 1 >
</cfif>

<cfif form.Email neq "">
<cfif SQL_Coubr eq 0>
<CFSET SQL = SQL& " WHERE " >
<cfelse>
<CFSET SQL = SQL& " OR " >
</cfif>
<CFSET SQL = SQL& " email LIKE '%#form.Email#%' " >
<CFSET SQL_Coubr = 1 >
</cfif>

<cfif form.Phone neq "">
<cfif SQL_Coubr eq 0>
<CFSET SQL = SQL& " WHERE " >
<cfelse>
<CFSET SQL = SQL& " OR " >
</cfif>
<CFSET SQL = SQL& " phone LIKE '%#form.Phone#%' " >
<CFSET SQL_Coubr = 1 >
</cfif>

<cfif form.ContractNumber neq "">
<cfif SQL_Coubr eq 0>
<CFSET SQL = SQL& " WHERE " >
<cfelse>
<CFSET SQL = SQL& " OR " >
</cfif>
<CFSET SQL = SQL& " conID LIKE '%#form.ContractNumber#%' " >
<CFSET SQL_Coubr = 1 >
</cfif>
<cfoutput>#SQL#</cfoutput>
<cfquery datasource="mssqlcf_modelprod" dbname="modelprod" name="get_prememb">
SQL
</cfquery>
</cfif>

moiseszaragoza
Newbie Poster
15 posts since Sep 2007
Reputation Points: 10
Solved Threads: 0
 

You have #SQL#
but in the cfquery you only have SQL, try enclosing the #SQL#

gdmprog1
Newbie Poster
3 posts since May 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You