sql apostrophe problem
Posted
#1
(In Topic #801)
Regular

I am importing data into an sql table ("temp") from a downloaded .csv file.
There are a few records containing an apostrophe e.g.
Code
PILGRIM'S PRIDE LT NO REF BGCBut a search containing that string with the apostrophe escaped fails
Code
hConn.Find("temp", "sMemo = '" & Replace(sVar, "'", "''") & "'")Any ideas would be welcome
Posted
Regular

bill-lancaster said
…But a search containing that string with the apostrophe escaped fails
…Any ideas would be welcome
The apostrophe can be a real pain because there are so many that look the same, but are different.
A quick look at an ASCII table and I see 5 'versions':-
dec 39
dec 96
dec 145
dec 146
dec 180
…so check the decimal or hex value.
Posted
Guru

Code (gambas)
Posted
Regular

I'd like to keep the string as it is.
All the characters in the string are either alphabet, space (32) or apostrophe(39) but the idea of other characters hadn't occurred to me.
Tried this:-
Code
Replace(sVar, "'", "\\'") Again thanks for your ideas on this tiresome issue.
1 guest and 0 members have just viewed this.


