I am having trouble with below ADOQuery quoted string %ABC%:
adoQuery1.SQL.Clear;
adoQuery1.SQL.Text := 'SELECT * FROM MyDB.MyTable WHERE MyField LIKE ''''%ABC%'''' ';
adoQuery1.ExecSQL;
adoQuery1.Close;
adoQuery1.Open;
I also tried to pass below parameter instead but no success:
adoQuery1.SQL.Clear;
adoQuery1.SQL.Text := 'SELECT * FROM MyDB.MyTable WHERE MyField LIKE :Param1 ';
aqBCCombi.Parameters.ParamByName('Param1').Value := '%ABC%';
adoQuery1.ExecSQL;
adoQuery1.Close;
adoQuery1.Open;
Here's the error I get: Parameter object is improperly defined. Inconsistent or incomplete information was provided.
Anyone here who knows how to handle quoted string within the ADO SQL text? Appreciate any help.
This code very similar to yours works for me:
You are using
ExecSQLfor a SELECT statement. Replace it withOpen.