to pjxy, 开个新贴呀。
procedure TForm1.CreateSubTree(StrProd_No,StrParent: string; Node: TTreeNode = nil);
var
mLocalName: string;
TreeNode: TTreeNode;
Ads_Tmp: TADODataSet;
begin
ADS_Tmp := TADODataSet.Create(application);
ADS_Tmp.Connection := ADOConn;
with ADS_Tmp do
begin
Close;
CommandText := 'Select * from Tbom Where Parent ='+#39+StrParent+#39
+' and prod_no='+#39+strProd_no+#39;
Open;
First;
while not Eof do
begin
mLocalName := FieldbyName('item_no').Asstring;
TreeNode := TV_BOM.Items.AddChild(Node, FieldByName('item_no').AsString);
CreateSubTree(StrProd_no,mLocalName, TreeNode);
Next;
end;
end;
end;