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

Selecting Data With an Apostrophe

Status
Not open for further replies.

LyndonOHRC

Programmer
Sep 8, 2005
603
US
I must be missing something simple, this apostrophe issue is getting the best of me...

I have an Access table of county names, one of them is O'Brien.

After reading all that I can find I've tried all of these queries but never get a record back. Please help I'm obviously confused.

I tried all three of these and I get zero records every time:
<code>
<cfquery name="GetTownshipDirection" datasource="SCRegistry">
Select id
From TownshipDirection
Where County=<cfqueryparam value="#PreserveSingleQuotes(GetCounties.countyname)#" cfsqltype="CF_SQL_VARCHAR">
</cfquery>

<cfquery name="GetTownshipDirection" datasource="SCRegistry">
Select id
From TownshipDirection
Where County=<cfqueryparam value="#GetCounties.countyname#" cfsqltype="CF_SQL_VARCHAR">
</cfquery>

<cfquery name="GetTownshipDirection" datasource="SCRegistry">
Select id
From TownshipDirection
Where County='#GetCounties.countyname#'
</cfquery>
</code>

Lyndon

---People Remember about 10% of what you say ---They never forget how you made them feel. Covey
 
Try doing a hard escape of the apostrophe, or single quote.

Select id
From TownshipDirection
Where County='#replace(GetCounties.countyname,"'","''")#'

Phil H.
-----------
A virtual machine ate my accounting data. I transferred it to a physical box, then I beat it to smithereens with a sledgehammer. I feel better.
 
My apologies, the user entered an accent` instead of a an apostrophe. It was almost impossible to tell.

Lyndon

---People Remember about 10% of what you say ---They never forget how you made them feel. Covey
 
You can search and replace for the accents and "Smart" (ha-ha) quotes by looking up the ASCII values and doing a replace on them. You'll run into this every time you allow a user to cut and paste data, especially if they're pasting from an Office document.

Phil H.
-----------
A virtual machine ate my accounting data. I transferred it to a physical box, then I beat it to smithereens with a sledgehammer. I feel better.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top