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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Oct 11, 2013, 10:07 AM
VulpesPosted Oct 11, 2013, 10:33 AM
If it doesn't, then Replace will have no effect.
Marvin kakuruPosted Oct 11, 2013, 10:26 AM
Marvin kakuruPosted Oct 11, 2013, 9:59 AM
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 kakuruPosted Oct 11, 2013, 9:57 AM
VulpesPosted Oct 11, 2013, 7:58 AM
When you search for a string s, say, try searching instead for:
s.Replace("'", "''")
In other words double the apostrophes.