[Gambas-user] Error ODBC

bb adamnt42 at gmail.com
Tue Jul 13 13:53:59 CEST 2021


On Tue, 2021-07-13 at 13:34 +0200, Hans Lehmann wrote:
> Public Sub btnDoTest_Click()
> 
>     Dim sSQLStatement As String
>     Dim dbResult As Result
>     
>     sSQLStatement = "SELECT vorname, nachname, gebdatum FROM contacts
> WHERE id BETWEEN 4 AND 7"
> 
>     DBConnection.Begin()
>       dbResult = DBConnection.Exec(sSQLStatement)
>     DBConnection.Commit()
>   
>     dbResult.MoveFirst()
>   
>     While (dbResult.Available)
>       Print dbResult!vorname & " " & dbResult!nachname & " ---▶ " &
> Format(dbResult["gebdatum"], "yyyy-mm-dd")
>       dbResult.MoveNext()
>     Wend
> 
> End
I am not totally conversant with Sqlite but...
1) You don't need the DBConnection.Begin() and Commit() as Select
doesn't need a transaction.
2) dbResult.Available just tells you there is some result. AFAIK you
should be using something like
	dbResult.MoveFirst
	Print dbResult!vorname & " " & dbResult!nachname ....

	While dbResult.MoveNext()
		Print dbResult!vorname & ... etc
	Wend

or is it While Not dbResult.MoveNext() ?
(can't remember)

hth
bruce






More information about the User mailing list