1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| procedure TForm1.Button1Click(Sender: TObject);
begin
// Check if we have an active connection. If so, let's close it.
if MySQL50Connection1.Connected then begin
SQLTransaction1.Active := False;
MySQL50Connection1.Close;
end;
// Set the connection parameters.
MySQL50Connection1.HostName := '127.0.0.1' ;
MySQL50Connection1.UserName := 'root';
MySQL50Connection1.Password := '';
MySQL50Connection1.DatabaseName := 'mysql'; // MySQL is allways there!
MySQL50Connection1.Open;
// First lets get a list of available databases.
if MySQL50Connection1.Connected then begin
SQLQuery1.SQL.Text := 'SHOW DATABASES' ; // ; 'SELECT * FROM user';
SQLQuery1.Open;
while not SQLQuery1.EOF do begin
DatabaseComboBox.Items.Add(SQLQuery1.Fields[0].AsString);
//DatabaseComboBox.Items.Add(SQLQuery1.FieldByName('host').AsString) ;
SQLQuery1.Next;
end;
SQLQuery1.Close;
end;
end; |
Partager