Recent Entries
Contact Doug!
Learn About Doug!
View Doug Boude's online resume
updated 11/18/2009

View Doug Boude's profile on LinkedIn
Link to me!

Follow Doug Boude on Twitter
Follow me!

Be Doug's friend on Facebook
Befriend me!
(I promise not to follow you home)
OO Lexicon
Chat with Doug!
You may also be interested in...
Web Hosting

<< October, 2011 >>
SMTWTFS
1
2345678
9101112131415
16171819202122
23242526272829
3031
Search Blog

Recent Comments
Re: November 7th, 2012 - Day 1 of the Restoration of America's Greatness (by dougboude at 5/04 9:47 AM)
Re: November 7th, 2012 - Day 1 of the Restoration of America's Greatness (by Simon Magnus at 5/04 9:24 AM)
Re: Providing for Service Layer Objects in CFWheels: Hello Wirebox! (by Brad at 5/03 11:37 AM)
Re: PayPal IPN Coldfusion CFC (by No at 4/29 9:28 AM)
Re: Java: The Journey Begins (by jwilliam at 4/23 11:56 PM)
Re: Providing for Service Layer Objects in CFWheels: Hello Wirebox! (by geirman at 4/21 10:24 AM)
Re: Providing for Service Layer Objects in CFWheels: Hello Wirebox! (by dougboude at 4/20 11:32 AM)
Re: Providing for Service Layer Objects in CFWheels: Hello Wirebox! (by geirman at 4/20 10:27 AM)
Re: The Model-Glue Event Lifecycle in Layman's Terms (by Ashwini at 4/18 2:51 PM)
Re: Viewing Option Text (in IE7) that's Wider than the Select List (by cormac at 4/18 4:18 AM)
Re: Providing For Service Layer Objects in CFWheels (by Chris Geirman at 4/16 2:04 PM)
Re: Why Provide for Service layer objects in CFWheels? (by dougboude at 4/13 9:13 AM)
Re: Why Provide for Service layer objects in CFWheels? (by Eric Cobb at 4/13 8:26 AM)
Re: Why Provide for Service layer objects in CFWheels? (by Chris Geirman at 4/13 6:44 AM)
Re: Why Provide for Service layer objects in CFWheels? (by Per Djurner at 4/12 3:39 PM)
Re: Refreshing Cached ColdFusion Webservices Through the Back Door (by Paul at 4/11 3:26 PM)
Re: Adding and Customizing Mura Editor Styles (by dougboude at 4/05 3:54 PM)
Re: Adding and Customizing Mura Editor Styles (by mike at 4/05 2:28 PM)
Re: Adding Mura Components to a Page Without Cascading (by Suzy Naschansky at 3/28 10:38 AM)
Re: Adding Mura Components to a Page Without Cascading (by Suzy Naschansky at 3/28 4:36 AM)
Categories
Archives
Photo Albums
Funnies (5)
Family (3)
RSS

Powered by
BlogCFM v1.11

07 October 2011
IRRITATING CF QUERY ERROR AND SOLUTION
Incorrect string value: '\xC2....'

Today I'd like to help save someone from pulling their hair out when they encounter a Coldfusion error similar to the following:

Error Executing Database Query. Incorrect string value: '\xC2\x96 OTH...' for column 'Comments' at row 1

This error would occur during a database insert or update, and very likely when trying to execute a query that does NOT use the CFQUERYPARAM tags.

TANGENT BEGIN

I'll just indulge the tangent for a moment since I mentioned doing something that ought not to be done and toss in at least one occasion when it is acceptable NOT to use them. When building a dynamic sql statement that you then want to execute, you cannot include cfqueryparam tags and have it work; CF will barf on it. Here's a rough example of what I'm talking about:

<cfset thisSQL = "INSERT INTO MYTABLE ('field1','field2',field3') VALUES (" />
<cfset thisSQL = "#thisSQL# '#val1#','#val2#','#val3#')" />
<cfquery name="qryInsert" datasource="#dsn#">
 #preserveSingleQuotes(thisSQL)#
</cfquery>

In that scenario, you can't use CFQUERYPARAM.

TANGENT END

Okay, back to the point. So you've built this dynamic sql statement, values being gotten by parsing some incoming text file, let's say, and when you try to execute your statement you get the "Error Executing Database Query. Incorrect string value: '\xC2\x96 OTH...' for column 'Comments' at row 1" error. Thinking the statement is malformed, you paste it directly into your favorite query analyzer to try and execute it directly in the database and it works fine. You then feed the same incoming data file to your test server to see if the error is consistent, but it works FINE on your test server.

(skip a lot of hair pulling and frustration...)

THE SOLUTION

The problem turns out to be that the incoming file contains high ascii values, or characters outside of the "safe zone", and for whatever reason, your server barfs on it (even though your test server and the db itself doesn't). The solution then is to strip out all high ascii values before trying to use the string in your sql statement. Like so:

<cfset val1 = rereplace(val1,"[^\x00-\x7F]","","all") />

That'll get rid of that pesky irritating useless error, for ya! You're welcome. No charge.

Posted by dougboude at 12:29 PM | PRINT THIS POST! | Link | 3 comments