Page 1 of 1

GetTabelNames will not refresh...

Posted: 13.01.2010, 09:52
by mikesmurph
Hi!

I have a Problem with the Function "GetTabelNames".

I don't Know who to Change the TabelNames when i select another Catalog.

My Example:

I have two Comboboxes. The first combobox represents the Cataloges, the second Combobox represents the Tables of the Selected Catalog.

The Selection of the first Combobox is filled with the following routine:

Code: Select all

    zConnection1.Protocol:=ProtokollComboBox.Text;
    zConnection1.HostName:=HostnamenEdit.Text;
    zConnection1.User:=userEdit.Text;
    zconnection1.Password:=passwordEdit.text;

    if zconnection1.Connected then
    Begin
      zConnection1.connected:=false;
      DBConnectLBL.Caption:='Nicht Verbunden...';
      jvconnectLED.Status:=false;
      katalogcombobox.items.Clear;
      tablecombobox.items.clear;
    end
    else
    Begin
      zConnection1.connected:=true;
      DBConnectLBL.Caption:='Verbunden...';
      jvconnectLED.Status:=True;
      zconnection1.GetCatalogNames(katalogcombobox.items);
    end;
After the selection of a Catalogname in that Combobox, the next Combobox have to filled with the tablenames of the selected catalog.
Therefore i have implemented folowing Procedure in the "onSelect"-Event of the Catalog-Combobox:

Code: Select all

procedure TForm1.KatalogComboBoxSelect(Sender: TObject);
begin
//      showmessage('Select gewählt');
      if zconnection1.Connected then
      Begin
            zconnection1.Catalog:=KatalogCombobox.Text;
            tablecombobox.Items.Clear;
            zconnection1.DbcConnection.GetMetadata.ClearCache;
            zconnection1.Reconnect;
            zconnection1.GetTableNames('','',tablecombobox.items);
      end;
end;
The Problem: The Result is always the same. Only three Tables will displayed. Any Changes in the Catalog-Combobox do not apply to the Tablebox....

Can anybody help me?!

Thanx

Michael

Posted: 13.01.2010, 14:00
by jeremicm
Try to put code in OnChange event instead of OnSelect... That will work i think?

Posted: 13.01.2010, 22:03
by mikesmurph
Hi jeremicm,

i have put the Code in "onChange", but the result ist the same.
The Tables-Items will not refreshed.

Any other Idea?
Database is on MySql, User is root-User..

Thx

Michael

:( :( :(

Posted: 19.01.2010, 00:16
by mdaems
I suppose closing the connection and opening it again with the new catalog instead of reconnect might work better. (I don't think reconnect is a full close/open operation)
Database instead of catalog would be better for mysql, I think.

Mark

Problem solved....

Posted: 28.01.2010, 13:09
by mikesmurph
Hi Mark,

thanks for Your help and your tip with the database. Now I have solved the Problem. its very Simple...

Code: Select all

procedure TForm1.KatalogComboBoxChange(Sender: TObject);
begin
      if zconnection1.Connected then
      Begin
            zconnection1.Database:=KatalogCombobox.Text;
            tablecombobox.Items.Clear;
            tablecombobox.Text:='';
            zconnection1.GetTableNames('%',zconnection1.Database,tablecombobox.items);
      end;

end;
This will function. :bash:

Michael