[Gambas-user] Set in a array all the tables' name of a database

Benoit Minisini gambas at ...1...
Thu Feb 26 17:27:42 CET 2004


On Thursday 26 February 2004 10:12, Linux wrote:
>   Hi,
>
> <In french for Benoit :)>
>
> Bonjour Benoit,
>
> Merci beaucoup pour ce magnifique outil qui met à la porter de beaucoup de
> débutants la conception d'applications graphiques élaborées sous Linux. Je
> te souhaite encore beaucoup de courage et d'envie pour que Gambas
> progresse toujours plus sur ce chemin d'excelence.
>
> Un grand Bravo
>
> </In french>
>
>  I would like to set in a array the name of all the tables from a
> specified dabase. But i don't anderstand how to use the virtual
> collection .
>
> Such an example of what i want to do :
>
>    DIM MyTable as TABLE
>    DIM iINC as INTEGER
>    DIM MyARRAY as string[]
>
>     iINC=0
>     FOR EACH MyConnection.Tables
>     MyTAble= MyConnection.Tables[iINC]   'This doesn't work :(
>     MyARRAY[iINC]=MyTable.name
>     INC iINC
>     NEXT
>
> Thanks a lot for your help
>
> Romain
>

The database component have many properties that are not real collections, but 
just an internal cursor to a object (like a Recordset in VB if you prefer).

But Tables is a real collection, and so can be enumerated with the FOR EACH 
instruction.

So, to get the name of each table of a specified database, do the following:

  DIM hTable AS Table
  DIM aTables AS NEW String[]
  
  FOR EACH hTable IN MyConnection.Tables
    aTables.Add(hTable.Name)
  NEXT

Regards,

-- 
Benoit Minisini
mailto:gambas at ...1...




More information about the User mailing list