I'm trying to build this query, but it's not working:
Using sDac 6.5.9, delphi XE, windows 7
   if (SearchString <> '') then
   begin
      gQuery.SQL.Add('select name,uid');
      gQuery.SQL.Add('from cust');
      gQuery.SQL.Add('where  IsActive =''true'' and name like ''%:sString%''');
      gQuery.SQL.Add('order by Name');
      gQuery.ParamByName('sString').AsString := SearchString;---error, parameter not found
Is my query bad, or is it the 'like' part of it?
			
									
									
						paramters and like
- 
				AndreyZ
 
Re: paramters and like
Hello,
You are using parameters in the wrong way. Your SQL code does not contain the sString parameter, it contains the '%:sString%' constant string. Here is a correct code:
			
									
									
						You are using parameters in the wrong way. Your SQL code does not contain the sString parameter, it contains the '%:sString%' constant string. Here is a correct code:
Code: Select all
if (SearchString <> '') then
begin
  gQuery.SQL.Add('select name,uid');
  gQuery.SQL.Add('from cust');
  gQuery.SQL.Add('where IsActive =''true'' and name like :sString');
  gQuery.SQL.Add('order by Name');
  gQuery.ParamByName('sString').AsString := '%' + SearchString + '%';Re: paramters and like
ty.  I think I figured that out at about 2 am thie morning in my sleep,when it came together.