GetTabelNames will not refresh...

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
mikesmurph
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 13.01.2010, 08:44

GetTabelNames will not refresh...

Post 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
jeremicm
Senior Boarder
Senior Boarder
Posts: 61
Joined: 18.10.2006, 17:07
Contact:

Post by jeremicm »

Try to put code in OnChange event instead of OnSelect... That will work i think?
mikesmurph
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 13.01.2010, 08:44

Post 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

:( :( :(
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post 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
Image
mikesmurph
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 13.01.2010, 08:44

Problem solved....

Post 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
Post Reply