Lazarus + MySQL tutorial lazarus / 16-Databases ---------------------------------------------------------------------- NickE · 2008-11-13 14:15 Hi, I tried out this example and it works fine. http://wiki.lazarus.freepascal.org/MySQLDatabases I understand most of code, but there are some parts of code what I can't figure out... For example I dont know why is it good to call CloseConnection (inc. MySQLConnection1.Close; ) when I click on "Select Database" button??? Code: [Select]procedure TFormTryMySQL.SelectDBButtonClick(Sender: TObject); begin   // A database has been selected so lets get the tables in it.   CloseConnection(Sender);   if DatabaseComboBox.ItemIndex <> -1 then begin     with DatabaseComboBox do       MySQLConnection1.DatabaseName := Items[ItemIndex];     ShowString('Retreiving list of tables');     SQLQuery1.SQL.Text := 'show tables';     SQLQuery1.Open;     while not SQLQuery1.EOF do begin       TableComboBox.Items.Add(SQLQuery1.Fields[0].AsString);       SQLQuery1.Next;     end;     SQLQuery1.Close;     ShowString('List of tables received');   end;   OpenQueryButton.Enabled := True; end; ---------------------------------------------------------------------- DougNettleton · 2008-11-14 16:44 Hi, Because you can't change the database name while the connection is active. HTH, Doug ---------------------------------------------------------------------- NickE · 2008-11-19 20:00 Thanks!