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 ...
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 ...
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 ...