[Gambas-user] result from select can be movefirts from ODBC?

Tobias Boege taboege at ...626...
Wed May 17 18:32:54 CEST 2017


On Wed, 17 May 2017, PICCORO McKAY Lenz wrote:
> i try to filla gridview at demand, so due ODBC limitations i cannot count
> so inside my bean-like object i count and tehen return properties..
> 
> the problem goes when i try to move to the fitrs record, i implement the
> code in wrong way? :
> 
> Try resulobj = $conexionodbc.Exec(exisqueryrequest)
> 
>   While (resulobj.Available)
> 
>     If resulobj.MoveNext() Then
>       resulhowmany = resulhowmany + 1
>     Else
>       Break
>     Endif
> 
>   Wend
> 
>   resulobj.MoveFirst ' <--- here said that its foward only, that's true if
> comes from a simple select ?
> 

I don't understand your last question (and I have no idea about bean-like
objects outside of gardening) but according to the Result.MoveNext()
documentation [1]:

  Returns TRUE if the result is void or if there is no next record.

You seem to increment your counter when the move *fails*, which will give
you a wrong count. I usually do something like:

  ' Modifies the internal Result record pointer!
  Private Sub CountResult(hRes As Result) As Integer
    Dim iCount As Integer

    If hRes.MoveFirst() Then Return 0
    iCount = 1
    While Not hRes.MoveNext()
      Inc iCount
    Wend
    Return iCount
  End

Regards,
Tobi

[1] http://gambaswiki.org/wiki/comp/gb.db/result/movenext

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




More information about the User mailing list