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

Hyphens(') problem

Status
Not open for further replies.

HotBob

Programmer
May 26, 2006
37
GB
What is the best way to deal with hyphens.

I am passing in a search name into a sql query but if the name has a hyphen such as strName = o'connor

Then I need to pass in the strName = o''connor

Other wise it errors

Any ideas?
 
Use stored procedures instead..

If you don't want to or can't for some reason, use the Replace() method on the string variable that holds the name to replace ' with ''

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
the best way in .NET side would be to use parameters. i think it does the same implicitly...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top