about "ZQuery.Open"

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
allegro
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 20.08.2008, 07:10

about "ZQuery.Open"

Post by allegro »

Code: Select all

  ZQuery2.SQL.Clear;
  ZQuery2.SQL.Add('select name from ip where ipstart< :pIP and ipend> :pIP ;');

repeat
...
    ZQuery2.Params[0].AsInteger:=iIP;
    ZQuery2.OPen;
    aRegion := VarToStr(ZQuery2['name']);  // only one record
...
until ...
only return the result for first time, why?
allegro
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 20.08.2008, 07:10

Post by allegro »

but this is ok.

Code: Select all

repeat 
... 
    TmpQuery := 'select name from ip2name where ipstart<' + nIP + ' and ipend>' + nIP + ';';
    ZQuery2.SQL.Clear;
    ZQuery2.SQL.Add(TmpQuery);
    ZQuery2.Open;
    aRegion := VarToStr(ZQuery2['name']);  // only one record 
... 
until ...
zippo
Silver Boarder
Silver Boarder
Posts: 322
Joined: 12.10.2005, 18:01
Location: Slovenia

Post by zippo »

You're not closig the dataset in the first example. Maybe this could work:

Code: Select all

  ZQuery2.SQL.Clear;
  ZQuery2.SQL.Add('select name from ip where ipstart< :pIP and ipend> :pIP ;');

repeat
...
    ZQuery2.Close;
    ZQuery2.Params[0].AsInteger:=iIP;
    ZQuery2.Open;
    aRegion := VarToStr(ZQuery2['name']);  // only one record
...
until ... 
zippo
Silver Boarder
Silver Boarder
Posts: 322
Joined: 12.10.2005, 18:01
Location: Slovenia

Post by zippo »

So... it's working?
Post Reply