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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Executing Database Query.

Status
Not open for further replies.

econdriak

MIS
Oct 24, 2002
4
US
I am having a problem adding info to my datasource. I have rebuilt the page and rebuilt the page using a <cfinsert> function as well. I still get the same error. All of my field names are correct and I have pages that perform the same function, just insert into the table.
My error message is giving me the error &quot;Error Executing Database Query&quot; however the error that the error message is nowhere in the query. The query is an insert query. Please help. I am on a deadline.
Here is the code of the query:
<cfquery datasource=&quot;MYDSN&quot;>INSERT INTO New(Name, Date, Message)
values('#Name#', '#Date#', '#Message#')
</cfquery>

The values are coming from a form this is the query on the process page.

It is telling me that the error is in line 20:
18 : <p><a href=&quot;courseadmin.cfm&quot;>Return to Course Administrator</a></p>
19 : </body>
20 : </html>
21 :
22 : </cfif>

What is going on? All of my other pages work with this same type query. My DSN Connection is fine.
Thanks
Please Help
 
seems like you may be using reserved words as column names -- New, Name, Date

or, the #Message# has a single quote in it, like O'Leary

try changing the CFQUERY to CFOUTPUT and see what it outputs, to see what the query actually says, then copy/paste that into, um, whatever frontend tool you use for your database

rudy
 
Thanks for the info r937, I tried the cfoutput and everything works fine. I don't think that column names are a problem given that the output page with the same column names works fine. Not to mention that I have tried changing all of the column names, rebuilt the table, changed the table name. Here is the code for the confirmation page:

<cfquery datasource=&quot;DSN&quot;>
INSERT INTO New
(Name,
Date,
Message)
VALUES('#Form.Name#',
'#Form.Date#',
'#Form.Message#')
</cfquery>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>
<body background=&quot;../Images/mainbackground.gif&quot;>
<p>The message</p>
<p><a href=&quot;courseadmin.cfm&quot;>Return to Administrator</a></p>
</body>
</html>

Here is the code for the form page:

<html>
<head>
<title>Whats New</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>

<body background=&quot;../mainbackground.gif&quot;>
<table width=&quot;650&quot; border=&quot;0&quot; cellspacing=&quot;0&quot;>
<tr bgcolor=&quot;#999999&quot;>
<td colspan=&quot;2&quot;><div align=&quot;left&quot;><font size=&quot;3&quot; face=&quot;Tahoma, Verdana, Arial&quot;>What's
New with you?</font></div></td>
</tr>
<tr>
<td colspan=&quot;2&quot;><font size=&quot;2&quot;>So what's new with you. Please write down what
is new so that it will be posted</font></td>
</tr>
<cfform action=&quot;wn2.cfm&quot;>
<tr>
<td width=&quot;115&quot;>Your Name: </td>
<td width=&quot;531&quot;><cfinput type=&quot;text&quot; name=&quot;Name&quot; size=&quot;50&quot;></td>
</tr>
<tr>
<td>What is the Date:</td>
<td><cfinput type=&quot;text&quot; name=&quot;Date&quot; size=&quot;50&quot;></td>
</tr>
<tr>
<td valign=&quot;top&quot;>Article:</td>
<td><textarea name=&quot;Message&quot; cols=&quot;45&quot; rows=&quot;10&quot;></textarea></td>
</tr>
<tr>
<td valign=&quot;top&quot;> </td>
<td><input type=&quot;submit&quot; value=&quot;Insert&quot;><input type=&quot;reset&quot; value=&quot;Reset&quot;></td>
</tr>
</cfform>
</table>

</body>
</html>

I am sure it is something simple. But I don't know what is going on.
 
still getting the database error?

change CFQUERY to CFOUTPUT so that you can see how

VALUES('#Form.Name#',
'#Form.Date#',
'#Form.Message#')

gets evaluated -- what are the values that are causing the database error?

... because your INSERT syntax is fine
 
Actually I gave up and just changed everything to <cfform>s and <cfinserts> and after I deleted all the problematic files and just started over with the table, the form, and the process page. Now it all works. Thanks for the help though!
gf
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top