Te puedes crear un función que te devuelva todas las bases de datos:
Código Delphi
[-]function TForm1.GetAllSysMSSDataBasesToStringsList: TStrings;
var
adoCnnTmp: TADOConnection;
ConnectionString: WideString;
begin
ConnectionString := 'Provider=SQLNCLI.1;' +
'Password=123;' +
'Persist Security Info=True;' +
'User ID=sa;' +
'Data Source=SERVIDOR\SQLEXPRESS';
adoCnnTmp := TADOConnection.Create(nil);
adoCnnTmp.Connected := False;
adoCnnTmp.LoginPrompt := False;
adoCnnTmp.ConnectionString := ConnectionString;
with TADOQuery.Create(nil) do
begin
Connection := adoCnnTmp;
SQL.Add('SELECT');
SQL.Add(' UPPER(name) AS DBNAME');
SQL.Add(' FROM sys.databases');
SQL.Add(' ORDER BY name');
Open;
Result := TStringList.Create;
while (not Eof) do
begin
Result.Add(FieldByName('DBNAME').AsString);
Next;
end;
adoCnnTmp.Free;
Free;
end;
end;
Después con un Button o en el OnCreate del formulario realizas:
Código Delphi
[-]...
begin
ComboBox1.Items.Assign(GetAllSysMSSDataBasesToStringsList);
end;
y eso es todo.
Un saludo.