我知道一个字段的内容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;
我知道我这样写,有问题,请大侠帮帮我!怎么写,不够分在加。。!
我现在想枚举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;
我知道我这样写,有问题,请大侠帮帮我!怎么写,不够分在加。。!
解决方案 »
- 急急急!!! 求Delphi通过修改 .tlb 文件的完整例子
- delphi 如何 获取 可执行文件的导入表?
- 2008年最后一张贴子哈哈
- ~~~~~~~~~~老婆一直想要孩子,可我想再等两年,没想到她昨晚竟然在套子上做手脚,把前边弄破了
- 100分问个问题 - pb写的dll,delphi调用问题。
- 如何用dbgrid显示文本中的数据?
- 在线等待:怎么样才能控制我的声卡发出1、2、3等这样的声音???
- 如何在QR中把一个字段的内容分行显示?
- 大家请帮忙,一个关于ADO在WINDOW 2000下的问题!??
- Delphi的更新包不认S/N和Athorization Key,怎么办呢?
- 很简单的问题,如何在窗体移动和改变大小后后ShowMessage('done')
- 如何做一下比较完整的查询体系,可以任意的查询出某一个人或某些人,我用的是sql库
function TForm1.findLeaf(parentid:integer):integer;
begin
with ADOQuery1 do begin
open;
if Locate( 'parentid',parentid,[]) then begin {找}
findLeaf(FieldByName('id').AsInteger); {用找到记录的id当父id继续找它的孩子}
end
else
result := ADOquery1.RecNo; {起到没有再找到时,返回该行的记录号}
end;
end;
对节点是是否是子节点用(HasChildren==TRUE)函数来判断.你要写来二个函数,先建立主体树,然后,叶子就然另一个函数去递归.全部完成树结构,然后全树再进行一边循环,把没有子节点的放B表,有子结点的放A表。