Link to home
Start Free TrialLog in
Avatar of rick_mulder
rick_mulder

asked on

TQuery and SQL String

I'm using this query:

QueryTest.SQL.Add('Select * from TEST where Name = "' + TableNames['NAME'] + '"');

Ok. this works fine until the query reaches someone with the name "abcdf".

So what's happens is that the string looks like :
Select * from TEST where Name = ""abcd"" !!!

I also tried this :
QueryTest.SQL.Add('Select * from TEST where Name = ''' + TableNames['NAME'] + '''');

Replacing the " with ' works but when now someone has a name with '''' in it, the same problem occurs.

Is there a solution to my problem??

Avatar of kretzschmar
kretzschmar
Flag of Germany image

hi rick_mulder

try

QueryTest.SQL.Add('Select * from TEST where Name = ' + quotedStr(TableNames['NAME'])');

meikl
ASKER CERTIFIED SOLUTION
Avatar of williams2
williams2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial