循环枚举问题,2天没搞点
我知道一个字段的内容A。。。通过这个字段A的内容去寻找一个目录树的sql-server的一张表。在表里面寻找A的子项,
我现在想枚举A子项里面的记录,有子节点的循环到里面,找出最后一级的内容添加到另外一张表。没有子节点的直接加入另外一张表。
procedure TchukuBaseFrame.add(id:string;mount:real);
var idstr:string;
begin
opensql(ado,'select id,artno,mount,sortname,parentid from sort where parentid='+quotedstr(id)+' and sortname is not null');
if not ado.IsEmpty then
begin
ado.First;
while not ado.Eof do
begin
idstr:=ado.fieldbyname('id').AsString;
opensql(ado1,'select id,artno,mount,parentid from sort where parentid='+quotedstr(idstr)+' and sortname is not null');
if ado1.IsEmpty then
begin
udb.SaveData('chukumx','id,Pitem,mount,memo',' '+quotedstr(master.fieldbyname('id').AsString)+','+quotedstr(ado.fieldbyname('artno').AsString)+','+quotedstr(floattostr(ado.fieldbyname('mount').AsFloat*mount))+','+quotedstr(lltemp.fieldbyname('yt').AsString));
end
else begin
id:=ado.fieldbyname('id').AsString;
mount:=mount*ado1.fieldbyname('mount').AsFloat;
add(id,mount);
end;
ado.Next;
end;
end;
end;
我知道我这样写,有问题,请大侠帮帮我!怎么写,不够分在加。。!