ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old July 27th, 2004, 04:53 PM
ericcnielsen ericcnielsen is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 6 ericcnielsen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Query error question

I am trying to develop a website using Cold Fusion and am currently working on some administrative pages. I've built a page with a textarea in which I can type an SQL statement and a submit button to execute the SQL.

This process works fine for any query that contains only numerical criteria. But, if I apply any kind of text-related criteria I get database errors.

Thus,
SELECT * FROM Team WHERE [ID]>23 ORDER BY [AgeGroup], [Name];
works perfectly, but

UPDATE Team SET [City]='MyTown' WHERE [ID]=29;
results in :
Message: ODBC Error Code = 37000 (Syntax error or access violation)
Detail: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression '''MyTown'''.

Any ideas?

TIA,
Eric

Reply With Quote
  #2  
Old July 27th, 2004, 08:11 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Try removing the brackets around the field names, they shouldn't be necessary.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old July 28th, 2004, 02:57 PM
ericcnielsen ericcnielsen is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 6 ericcnielsen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by kiteless
Try removing the brackets around the field names, they shouldn't be necessary.


I've done that...I've also tried using both single- and double-quotes, all result in an error.

Reply With Quote
  #4  
Old July 28th, 2004, 04:34 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Can you show the SQL and the error that is generated once you are running it without the brackets? Also, remove the semicolons...CF automatically terminates the statement with a semicolon.

Reply With Quote
  #5  
Old August 3rd, 2004, 11:54 AM
ericcnielsen ericcnielsen is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 6 ericcnielsen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by kiteless
Can you show the SQL and the error that is generated once you are running it without the brackets? Also, remove the semicolons...CF automatically terminates the statement with a semicolon.



This is the SQL I type into the textarea:
UPDATE Team SET City = 'SomePlace' WHERE ID = 9

This is the resulting error:

DATABASE Error
An error occured executing the following:

UPDATE Team SET City = 'SomePlace' WHERE ID = 9


Error details:

Message: ODBC Error Code = 37000 (Syntax error or access violation)

Error code: -3100
SQLState: 37000
Detail: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression '''SomePlace'''.

Reply With Quote
  #6  
Old August 3rd, 2004, 03:00 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
And you can run this query:

UPDATE Team SET City = 'SomePlace' WHERE ID = 9

From inside Access and it works?

Reply With Quote
  #7  
Old August 3rd, 2004, 03:50 PM
ericcnielsen ericcnielsen is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 6 ericcnielsen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by kiteless
And you can run this query:

UPDATE Team SET City = 'SomePlace' WHERE ID = 9

From inside Access and it works?



Yes, that is correct and why I am baffled.

This also works just fine:
UPDATE Team SET Wins = 5 WHERE ID = 9

I only get these errors when I attempt to set values or criteria on string data, so a query like

SELECT * FROM Team WHERE State = 'WA'

yields the following:

DATABASE Error
An error occured executing the following:

SELECT * FROM Team WHERE State = 'WA'


Error details:

Message: ODBC Error Code = 37000 (Syntax error or access violation)

Error code: -3100
SQLState: 37000
Detail: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'State = ''WA'''.

Reply With Quote
  #8  
Old August 3rd, 2004, 11:05 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Does it want double quotes possibly?

Reply With Quote
  #9  
Old August 4th, 2004, 11:17 AM
ericcnielsen ericcnielsen is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 6 ericcnielsen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by kiteless
Does it want double quotes possibly?


Nope, tried that, get the same result with either.

Reply With Quote
  #10  
Old August 4th, 2004, 02:27 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Try hard coding the SQL...so instead of trying to use a form variable, do this:

<cfquery name="blah".....>
UPDATE Team SET City = 'SomePlace' WHERE ID = 9
</cfquery>

Does that work?

I'm at a loss at this point, because I've never had such a problem...obviously CF *does* allow you to do database UPDATES, INSERTS, or any other valid SQL operation, so there must be something wrong somewhere in your specific environment, I just can't tell what it is.

Reply With Quote
  #11  
Old August 4th, 2004, 03:47 PM
ericcnielsen ericcnielsen is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 6 ericcnielsen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by kiteless
Try hard coding the SQL...so instead of trying to use a form variable, do this:

<cfquery name="blah".....>
UPDATE Team SET City = 'SomePlace' WHERE ID = 9
</cfquery>

Does that work?

I'm at a loss at this point, because I've never had such a problem...obviously CF *does* allow you to do database UPDATES, INSERTS, or any other valid SQL operation, so there must be something wrong somewhere in your specific environment, I just can't tell what it is.


Yes, that works...so that means, what? The textarea somehow modifies the ' mark, so that when it gets passed to the action template it is not processed as a ' ? If that's the case I can't immediately think of a work-around.

Reply With Quote
  #12  
Old August 4th, 2004, 04:55 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Form data is always URL encoded. You could try using urlDecode() to force it back.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Query error question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |