Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 37000 1

Status
Not open for further replies.

jduawa

MIS
Jun 11, 2002
73
US
What i have here is a simple form that i would like to enter sql commands on, thus the form being submitted to itself and performing the query. However, When i do a select this code works but if i try to do an update from this page i get an odbc 37000 error.
thanks
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>

<html>
<head>
<title>Untitled</title>
</head>

<body>

<cfif IsDefined(&quot;PAGEACTION&quot;)>
<cfquery name=&quot;ffdb&quot; datasource=&quot;football&quot;>
#FORM.Q#
</cfquery>
<cfoutput>
<cfdump var=&quot;#ffdb#&quot;><br>
</cfoutput>
</cfif>
<cfform action=&quot;#cgi.script_name#&quot; method=&quot;Post&quot; name=&quot;QForm&quot;>
<input type=&quot;HIDDEN&quot; name=&quot;PageAction&quot;>
Query<br>
<textarea cols=&quot;60&quot; rows=&quot;8&quot; name=&quot;Q&quot; wrap=&quot;virtual&quot;></textarea><br>

<input type=&quot;Submit&quot; value=&quot;Submit&quot;>
</cfform>
</body>
</html>

the database i am using is MS access 97
I also tried sql server 2000 and got the same error
Cf Server version is 5.0

here is the update query
------------
update users set real_name='Jim' where user_id=1
-----------
table name is users
Here is the error message
------------
Error Occurred While Processing Request
Error Diagnostic Information
ODBC Error Code = 37000 (Syntax error or access violation)


[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression '''Jim'''.



The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position (11:2) to (11:44).




update users set real_name='Jim' where user_id=1

 
Change your query to:
Code:
<cfquery name=&quot;ffdb&quot; datasource=&quot;football&quot;>
#PreserveSingleQuotes(FORM.Q)#
</cfquery>
As your code stands now, ColdFusion is automatically escaping the single quotes because you are dynamically generating the SQL code.

-Tek
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top