还有 你看这怎么搞的?


一添加反而多出重复的城市和医院了、
是建树 的时候 循环出错么?
这是代码
begin
rootnode:=tv1.items.addchild(nil,'客户');
regionnode :=tv1.items.addchild(rootnode,dscity.fieldbyname('region').AsString);
with dscity do
begin
active := false;
commandtext :='select distinct city ,hospital,telephone,contact from customer order by city';
active :=true;
end;
dscity.first;
if not dscity.eof then
for i := 0 to dscity.recordcount - 1 do
begin
citynode :=tv1.Items.addchild(regionnode,dscity.fieldbyname('city').AsString);
with dshos do
begin
active :=false;
commandtext :='select * from customer where city =:c';
Parameters[0].Value:=citynode.Text;
active :=true;
end;
if not dshos.eof then
for j := 0 to dshos.recordcount - 1 do
begin
hospitalnode:= tv1.Items.addchild(citynode,dshos.fieldbyname('hospital').asstring);
dshos.next;
end;
dscity.next;
end;
end;