Problems using ZQuery

The official tester's forum for ZeosLib 7.1. Ask for help, post proposals or solutions.
Post Reply
Artem_
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 13.11.2013, 08:54

Problems using ZQuery

Post by Artem_ »

Hi all/ I have Lazarus 1.2RC1 and ZeosDBO 7.1.2 stable

Code: Select all

RequestHardwares.Close;
if not MainWND.TB_Apply_Filter.Down then
   RequestHardwares.SQL.Strings[RequestHardwares.SQL.Count-1]:='where hardwares."HW_Location"='
                                                           +{CabinetsTable}RO_Cabinets.Fields[0].AsString+';'
else begin
//  MainWND.DoFilterActionClick(nil);
   exit;
end;
RequestHardwares.Open;
{Here i gon an error: cannot perform... to inactive dataset
i must prevent to entering displaying data procedure when no data was returned}
if RequestHardwares.RecordCount=0 then exit;
FillList;
My code generates a SELECT SQL statement. But when generated query returns an empty dataset,
i got error when trying to check RecordCount property. Whats wrong in my code? Or this is normal? Please answer me.
P.S. same code in delphi cause NO error when dataset is empty (reccount returns zero)

Thanks.
User avatar
Sergiomaster
Fresh Boarder
Fresh Boarder
Posts: 24
Joined: 13.06.2011, 12:37

Re: Problems using ZQuery

Post by Sergiomaster »

Hello,

quotes for value missing in your code
Prefer at least a Quotedstr

Code: Select all

   RequestHardwares.SQL.Strings[RequestHardwares.SQL.Count-1]:='where hardwares."HW_Location"='+Quotedstr(                                                       {CabinetsTable}RO_Cabinets.Fields[0].AsString)
better should be a parameter

Code: Select all

   RequestHardwares.SQL.Strings[RequestHardwares.SQL.Count-1]:='where hardwares."HW_Location"=:H';
            RequestHardwares.paramByName('H').asSTring:={CabinetsTable}RO_Cabinets.Fields[0].AsString);
Main uses Delphi3/7/2010/Rio 10.3/Sidney 10.4 + Interbase/Firebird
Post Reply