MSQuery Where ?

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
tiger
Posts: 2
Joined: Mon 02 Apr 2012 07:27

MSQuery Where ?

Post by tiger » Mon 02 Apr 2012 07:59

I am first using your SDAC. I using Migation BDE TO SDAC.
When BDE Query1 Select Command:

with Query1 do
begin
CLose;
SQL.Clear;
SQL.Add('select * from table1 where field1="'+Edit1.Text+'"');
if not Prepared then Prepare;
Open;
end;
But, In SDAC MSQuery, Program run Error
Error Message: inValid Fieldname
I can't change SQL.Add('select * from table1 where field1=:field1') ,
because My program to much, Pleae tell my, How to do.
Thank you

AndreyZ

Post by AndreyZ » Tue 03 Apr 2012 12:48

Hello,

To solve the problem, you should replace double quotes in your query with the pair of single quotes. Here is a code example:

Code: Select all

with Query1 do
begin 
  Close;
  SQL.Clear;
  SQL.Add('select * from table1 where field1='''+Edit1.Text+'''');
  if not Prepared then Prepare;
  Open;
end;

Post Reply