hi there,
i am trying to search my database, but when i search a customer name for example " Hellen's " which contains a hyphen, i get a syntax error.
can anyone me help out?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Oct 11, 2013, 6:07 AM EDT
VulpesRank #55 · 29.2K reputationPosted Oct 11, 2013, 3:58 AM EDT
When you search for a string s, say, try searching instead for:
s.Replace("'", "''")
In other words double the apostrophes.
Marvin kakuruRank #3,979 · 374 reputationPosted Oct 11, 2013, 5:57 AM EDT
Marvin kakuruRank #3,979 · 374 reputationPosted Oct 11, 2013, 5:59 AM EDT
below is my sting b4 i add the double apostrophes.
string sqll = ("select uic,namehu,phyaddress,contactinfor,emaila,joinedon,expireson from clientinfor where namehu LIKE '%" + textBox1.Text + "%' or phyaddress LIKE '%" + textBox1.Text + "%' or uic LIKE '%" + textBox1.Text + "%'");
thanks again man.marvin
Marvin kakuruRank #3,979 · 374 reputationPosted Oct 11, 2013, 6:26 AM EDT
VulpesRank #55 · 29.2K reputationPosted Oct 11, 2013, 6:33 AM EDT
If it doesn't, then Replace will have no effect.