[Gambas-user] sqlite gambas table info?

Tobias Boege taboege at ...626...
Fri Jun 16 22:17:28 CEST 2017


On Fri, 16 Jun 2017, PICCORO McKAY Lenz wrote:
> its there some code to get BEFORE send the query the fields of the table?
> 
> i mean, in the following code example i already know the column name, but i
> need firts detect column name to send amount of filters
> 
> sCriteria *=* "id = &1"iParameter *=* *1012*$hConn*.*Begin' Same as
> "SELECT * FROM tblDEFAULT WHERE id = 1012"hResult *=*
> $hConn*.*Edit*(*"tblDEFAULT"*,* sCriteria*,* iParameter*)*
> 
> 
> in this case, the column "id" was previously knowed! but in my case i need
> to detect all the column names firts before send the filters/parameters
> criteria
> 
> please any help?
> 

Look again at the properties of the Connection object. To get information
about a table, the "Tables" property is a good start. If your Connection
is called h you can list all tables, their fields and datatypes like this:

  ' h is an open connection to a database
  Dim t As Table, f As Field

  For Each t In h.Tables
    Print t.Name
    For Each f In t.Fields
      Print "  "; f.Name;; f.Type
    Next
  Next

Use

  t = h.Tables["<your_tablename>"]

in place of the outer loop if you only care about a specific table.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list