Procedure TForm1.Treeviewfill();
var
DB, Tab ,Fld, DBG : TTreeNode;
Min_DB, Max_DB, Min_Tab, Max_Tab, Min_Fld, Max_Fld, i_db, i_tab, i_fld : Integer;
name:
string;
begin
Symbole();
// aufrufen der prozedur Sysmbole
with TreeView1.Items
do // füllen der Treeview mit Datenbanken deren Tabellen und Felder
begin
DBG := Add(
nil, '
Datenbanken' );
SP_Databases.Active := true;
Min_DB := 0;
Max_DB := DS_Databases.DataSet.RecordCount;
//Maximale anzahl von Datenbanken auf dem Recher ermitteln
DS_Databases.DataSet.First;
for i_db:=Min_DB
to Max_DB - 1
do
begin
DB:= AddChild(DBG, DS_Databases.DataSet.Fields.Fields[0].AsString);
// hauptknoten (Datenbanken)
Q_Tables.SQL.Text := '
USE ' + DS_Databases.DataSet.Fields.Fields[0].AsString;
//
Q_Tables.ExecSQL;
SP_Tables.Parameters.Items[3].Value := DS_Databases.DataSet.Fields.Fields[0].AsString;
// Datenbankenname übergabe an die Unterknoten mit den Tabellen
SP_Tables.Active := true;
Min_Tab := 0;
Max_Tab := DS_Tables.DataSet.RecordCount;
DS_Tables.DataSet.First;
for i_tab:= Min_Tab
to Max_Tab-1
do
begin
Tab:= addchild(
Db, DS_Tables.DataSet.Fields.Fields[2].AsString);
Q_Fields.SQL.Text:= '
Use '+ DS_Databases.DataSet.Fields.Fields[0].AsString;
Q_Fields.ExecSQL;
// if uppercase(DS_Tables.DataSet.Fields.Fields[2].AsString) = 'SYSCOLUMNS' then
// begin
Selected_Table := DS_Tables.DataSet.Fields.Fields[2].AsString;
if Selected_Table = '
'
then
begin
Selected_Table := '
dbo.sysaltfiles'
end;
Selected_Qualifier := DS_Databases.DataSet.Fields.Fields[0].AsString;
if Selected_Qualifier = '
'
then
begin
Selected_Qualifier := '
master'
end;
SP_Field.Parameters.ParamByName('
@table_name').Value:= Selected_Table;
SP_Field.Parameters.ParamByName('
@table_qualifier').Value := Selected_Qualifier;
SP_Field.Open;
Sp_Field.Active := True;
//SP_Field.ExecProc;
Min_Fld := 0;
Max_Fld := DS_Field.DataSet.RecordCount;
DS_Field.DataSet.First;
for i_fld := Min_Fld
to Max_Fld
do
begin
Tab.ImageIndex := 3;
//if DS_Field.DataSet.Fields.Fields[2].AsString = Selected_Table then
AddChild(Tab, DS_Field.DataSet.Fields.Fields[3].AsString);
DS_Field.DataSet.Next;
end;
// end;
DS_Tables.DataSet.Next;
end;
SP_Tables.Active := false;
DS_Databases.DataSet.Next;
end;
end;
end;