Help - database and tablenames

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
reab
Posts: 6
Joined: Thu 26 Apr 2007 09:57

Help - database and tablenames

Post by reab » Thu 26 Apr 2007 12:43

Hi all,
Just trying the evaluation version to access a Firebird 2.0 database for high speed local data logging operations and I hope to achieve better portability/deployment.
Having installed the InterBase Data Access Components with no problems, what do I need to do to retrieve the database names and table names to place into a list/combobox?
I've tried the following:

Code: Select all

databasenames.items := GetDatabaseNames (databasenameslist);
Where databasenames.items is a combobox and 'databasenameslist' is a local procedure variable.
Delphi 2005 considers 'GetDatabaseNames ' to be an undeclared variable - so what should I have declared or referenced.
Sorry for such a simple question but I could find no mention of this anywhere!

Roger B

Alex
Posts: 655
Joined: Mon 08 Nov 2004 08:39

Post by Alex » Thu 26 Apr 2007 13:18

There is no GetDataBaseNames method in IBDAC because InterBase/Firebird server doesn't provide interfaces for such things.
To retrieve database tables list, you can use the TIBCConnection.GetTableNames method after connecting to the appropriate database.

reab
Posts: 6
Joined: Thu 26 Apr 2007 09:57

Post by reab » Fri 27 Apr 2007 09:12

OK - thanks for that Alex, I may have stumbled in my efforts to get moving.

I can see the data base and select a table to view in a DBGrid which looks OK.
What I want to do is retrieve the list of user tables which I can see in the property:
IBCTable1.Database.TableName
I can select a table from the dropdown here and display it in the DBGrid quite OK whilst in design mode.

So, I didn't understand when you suggested to retrieve this list with 'TIBCConnection.GetTableNames' as I cannot find this property. I'm trying to populate the combobox in a form 'oncreate' procedure by the way.

Can you possibly offer a simple code snippet to get me off the mark so that I can progress with the evaluation?

Thanks

Roger B

Alex
Posts: 655
Joined: Mon 08 Nov 2004 08:39

Post by Alex » Fri 27 Apr 2007 10:49

Place the TIBCConnection, TComboBox and TButton objects on the form
Double click on the button and write the following code:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
begin
//1. Connect the IBCConnection
IBCConnection1.Server := 'Localhost';
IBCConnection1.Database := 'D:\Test.gdb';
IBCConnection1.Username := 'SYSDBA';
IBCConnection1.Password := 'masterkey';
IBCConnection1.Connect;
//2. Retrieve dtabase tables
IBCConnection1.GetTableNames(ComboBox1.Items, True); //Second parameter detrmine if we need to return system tables
//Select the first table
ComboBox1.ItemIndex := 1;
end;
The TComboBox object will be filled with tables names from the D:\Test.gdb database.

reab
Posts: 6
Joined: Thu 26 Apr 2007 09:57

Post by reab » Fri 27 Apr 2007 11:21

Many thanks - that works well and I'm back on course again!

Roger B

Post Reply