ketankshah
IS-IT--Management
i have created 2 cfm pages. First one is accepting a sql statement in a form (text area) and the second page is executing the entered statement. I am getting an error while executing the statement in which I use a string value in the where criteria
(i.e. select * from module where module_name = 'TEST'). The error I get is 'Invalid syntax near 'TEST'. If I use a numeric value it works fine (i.e. select * from module where module_id = 3).
How to overcome this error ?
Please help.
I am attaching the pages.
-----------------------------------------------
The source code of the 2nd file is as follows
-----------------------------------------------
<html>
<head>
<title>SQL Execution</title>
</head>
<body>
<!---
Variables coming from a form in sql.cfm
db = database selection
select = sql statement for select query
show = column names (separated with commas) to be displayed
--->
<cfif db EQ "B">
<cfquery name="sql" datasource="#application.ds_service#">
#select#
</cfquery>
<cfelse>
<cfquery name="sql" datasource="#application.ds#">
#select#
</cfquery>
</cfif>
<cfif show NEQ "">
<cfoutput query="sql">
<cfloop index="list_elements" list="#show#" delimiters=",">
#Evaluate(list_elements)#
</cfloop>
<br>
</cfoutput>
</cfif>
</body>
</html>
-----------------------------------------------
Ketan
(i.e. select * from module where module_name = 'TEST'). The error I get is 'Invalid syntax near 'TEST'. If I use a numeric value it works fine (i.e. select * from module where module_id = 3).
How to overcome this error ?
Please help.
I am attaching the pages.
-----------------------------------------------
The source code of the 2nd file is as follows
-----------------------------------------------
<html>
<head>
<title>SQL Execution</title>
</head>
<body>
<!---
Variables coming from a form in sql.cfm
db = database selection
select = sql statement for select query
show = column names (separated with commas) to be displayed
--->
<cfif db EQ "B">
<cfquery name="sql" datasource="#application.ds_service#">
#select#
</cfquery>
<cfelse>
<cfquery name="sql" datasource="#application.ds#">
#select#
</cfquery>
</cfif>
<cfif show NEQ "">
<cfoutput query="sql">
<cfloop index="list_elements" list="#show#" delimiters=",">
#Evaluate(list_elements)#
</cfloop>
<br>
</cfoutput>
</cfif>
</body>
</html>
-----------------------------------------------
Ketan