[Gambas-user] Error ODBC

Christof Thalhofer chrisml at deganius.de
Tue Jul 13 17:20:00 CEST 2021

Hi Hans,

Am 13.07.21 um 14:16 schrieb Hans Lehmann:

> regardless of which suggestion I implement - the result remains the
> display of the first record.
> Or it results in an (additional) error:

Can you tell the number of 'DbResult.Count'? I always use another way to
iterate through the tuples of a result. To call 'Result.Available' seems
to be the wrong question, because it only seems to say if tuples are
available or not:

"Returns True if the result object contains one or more accessible
database rows."

This should be always the case, if the Result contains tuples at all,
even if your program iterated through all until the end of the result set.

I usually do it this way (sry i use my own naming not your's):

>     Dim qry As String
>     Dim res As Result
>     qry = "SELECT vorname, nachname, gebdatum FROM contacts WHERE id BETWEEN 4 And 7;"
>     res = DBConnection.Exec(qry)
>     'Print res.Count
>     If res.Count > 0 Then
>         For Each res
>             Print res!vorname & " " & res!nachname & " ---▶ " & Format(res["gebdatum"], "yyyy-mm-dd")
>         Next
>     Endif

(not tested)

And do you really want to use odbc? odbc is a crutch that we only use
when there is no direct way of accessing the database. But Gambas can
access Sqlite databases directly:


Alles Gute

Christof Thalhofer

[x] nail here for new monitor

More information about the User mailing list