[此贴子已经被作者于2004-09-08 11:12:16编辑过]
[此贴子已经被作者于2004-09-08 11:12:16编辑过]
我分开三个表
T1,T2,T3
procedure TForm1.Button1Click(Sender: TObject);
var
sqlStr:String;
begin
if self.ADOTable1.Active then
Self.ADOTable1.Close;
Self.ADOTable1.Open;
Node:=Self.TreeView1.Items.Add(nil,'ALL');
While Not Self.ADOTable1.Eof do
begin
ChildNode:=Self.TreeView1.Items.AddChild(Node,Trim(Self.ADOTable1.FieldByName('TcName').AsString));
ChildNode.Data :=Pointer(Trim(Self.ADOTable1.FieldByName('TcID').AsString));
sqlStr:='Select * from SchoolCode Where ScID Like '''
+Trim(Self.ADOTable1.FieldByName('TcID').AsString)
+'%''';
if Self.ADOQuery1.Active then
Self.ADOQuery1.Close;
Self.ADOQuery1.SQL.Clear;
Self.ADOQuery1.SQL.Add(sqlStr);
Self.ADOQuery1.Open;
While Not Self.ADOQuery1.Eof do
begin
Child1Node:=Self.TreeView1.Items.AddChild(ChildNode,Trim(Self.ADOQuery1.FieldByName('scName').AsString));
Child1Node.Data:=Pointer(Trim(Self.ADOQuery1.FieldByName('ScID').AsString));
Self.ADOQuery1.Next;
end;
Self.ADOTable1.Next;
end;
Self.TreeView1.FullExpand;
end;
用什么三个表,一个表就够了