On 3/13/03, Ian Skinner penned: >I think I have known this, but my brain is refusing to divulge the details. > >I have strings from a form that will be complete prose sentences and >paragraphs that need to be inserted into SQL 2000 char and varchar fields >with all their possible punctuation. What I can't remember is the best way >to handle the string so that the punctuation won't cause error's in the SQL >statement. > >For Example, I would be inserting text such as this: > >As I'm sure you know, all this punctuation would probably "cause" problems >when inserted. Don't you all think so? > >What is the easiest way to correctly insert strings such is this?
You should simply be able to use '#string#'. the only time you SHOULD need to escape characters is if you hard code them in. <cfset string = "I'm going to work"> SQL would be field='#string#' Entering it manually, the SQL would be field='I''m going to work' It's worked like this for me since CF 4.01. Of course CFMX breaks this at random with no rhyme nor reason. I've found that putting the cfquery in a cfinclude by itself fixes that bug. >On a related side problem. Anybody know any elegant work around that allow >the values from a set of related Form controls returned as a list to contain >commas (,)? > >For Example: > ><input type="text" name="TextField" value="Testing, one two three."> ><input type="text" name="TextField" value="You see, there are commas here. >And, multiple sentences."> ><input type="text" name="TextField" value="Comma, Comma, Comma"> > >Of course this then returns a Form.Field element with the following value. > >Form.TextField = Testing, one two three.,You see, there are commas here. >And, multiple sentances.,Comma, Comma, Comma > >As you can see, parsing this as a list with a default comma delimiters is >going to return 8 items instead of the correct 3. Is there an easy way to >incorporated a text qualifier and/or alternate list delimiters into the >values returned by a Form list? > >A compounding issue, is that I don't know how many "TextField" fields that >will be returned, the user can dynamically create as many has he needs. Don't know of a simple way to fix this. What I would do in this situation is number the fields using whatever mechanism you use to allow the user to select the number he needs. If he makes 3 fields: <input type="text" name="TextField1" value="Testing, one two three."> <input type="text" name="TextField2" value=""> <input type="text" name="TextField3" value="Testing, four five six."> Then loop through the form.fieldnames variable for the values. -- Bud Schneehagen - Tropical Web Creations _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ColdFusion Solutions / eCommerce Development [EMAIL PROTECTED] http://www.twcreations.com/ http://www.cf-ezcart.com/ 954.721.3452 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

