combobox_database.Clear; with Adoquery_temp do begin Close; Sql.Clear; Sql.Add('USE master SELECT dbid, DB_NAME(dbid) AS DB_NAME FROM sysdatabases ORDER BY dbid'); Open; First; while not eof do begin combobox_database.Items.Add(FieldBYName('db_name').AsString); next; end; lbl_database_count.Caption :=inttostr(recordcount); end; combobox_table.Clear; adoconnection1.GetTableNames(combobox_table.Items,false);
不行,楼上的是mssql,而不是mysql.用GetDatabaseNamesMyStringList := TStringList.Create; try Session.GetDatabaseNames(MyStringList); { fill a list box with database names for the user to select from } ListBox1.Items := MyStringList; finally MyStringList.Free; end;
with Adoquery_temp do
begin
Close;
Sql.Clear;
Sql.Add('USE master SELECT dbid, DB_NAME(dbid) AS DB_NAME FROM sysdatabases ORDER BY dbid');
Open;
First;
while not eof do
begin
combobox_database.Items.Add(FieldBYName('db_name').AsString);
next;
end;
lbl_database_count.Caption :=inttostr(recordcount);
end;
combobox_table.Clear;
adoconnection1.GetTableNames(combobox_table.Items,false);
try
Session.GetDatabaseNames(MyStringList);
{ fill a list box with database names for the user to select from }
ListBox1.Items := MyStringList;
finally
MyStringList.Free;
end;