Page 1 of 1

Problems using ZQuery

Posted: 13.11.2013, 09:10
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.

Re: Problems using ZQuery

Posted: 15.11.2013, 08:12
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);