DNNDev.com Forums Minimize
Replace ' Character
Last Post 03 Sep 2010 04:28 PM by Angus Beare. 1 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
raymac
New Member
New Member
Posts:1
Avatar

--
02 Sep 2010 08:46 PM  
I'm passing parameters to an XMod page to search a database, sometimes a search parameter will be O'Reilly which messes up the SQL Query.

Here is the XMod code:

<ListDataSource CommandText="SELECT ID, CharityName, City, RAScore, Province, Country, MissionStatement, RegistrationNum, RAScore FROM CharityProfiles WHERE RAScore is not null AND CharityName like '' + @SearchName + '' AND CharityType like '' + @SearchType + '' AND Province like '' + @Province + '' Order by ABS(RAScore) ">

<parameter name="SearchName" value='[[Url:Name]]' />
<parameter name="SearchType" value='[[Url:Type]]' />
<parameter name="Province" value='[[Url:Prov]]' />

</ListDataSource>

How can I replace the "'" character with a "''" character in the SearchName or Url:Name??
Angus Beare
Advanced Member
Advanced Member
Posts:753
Avatar

--
03 Sep 2010 04:28 PM  
I think if you use a stored procedure instead of embedded SQL you will not have a problem.

I have a site that sends some free text to a url parameter and filters a template.

I tried it with "O'Reilly" and it searched fine. The parameter came back into the search form with
two apostrophes. So O'Reilly became O''Reilly which means the SP added the extra apostrophe.

gus
if the only tool you have is a hammer you tend to see every problem as a nail.. http://www.carawaydesign.com
You are not authorized to post a reply.

Active Forums 4.1
spacer
dummy