[Gambas-user] Database not working to select records, but fields/tables identified
Fabien Bodard
gambas.fr at ...626...
Fri Jul 1 11:30:00 CEST 2011
While res.Available
res.MoveNext
Print "Field1: " & res["Field1"]
Wend
me i do that :
For each res
Print "Field1:" & res!Field1
next
It's more simple no ?
2011/7/1 Caveat <Gambas at ...1950...>:
> Hi,
>
> I'm trying to get database access to an ODBC datasource (have been
> trying for a few days now).
>
> I have the simplest Access (.mdb) database in the world: one table
> called people, with an id, a first name, a last name, and a phone
> number. There is no password on the database. I can see data in the
> people table if I use MDB Viewer (i.e. the table 'people' is NOT
> empty!).
>
> Thanks to a tip from Ricardo, I have gotten as far as a good connection,
> can see the ResultFields in the Result as expected (4 of them, with the
> expected column names), I get the appropriate error if I deliberately
> choose an invalid tablename (like persons for e.g.)... all good...
> but...
>
> I can't seem to get any kind of actual results in my result set,
> Result.Available seems to always be False although I know there's data
> in the table.
>
> This is also the case if I run the Database example in Gambas3, so I'm
> guessing it's not just my shoddy coding lol
>
> Here's the code I used (but note **it doesn't work** with the Database
> example either!):
>
> Public Sub tryNewDB()
>
> Dim conn As Connection
> Dim res As Result
> Dim sql As String
> Dim resF As ResultField
> conn = Connections["NEWDB"]
> conn.Open
> sql = "select * from people"
> res = conn.Exec(sql)
> For Each resF In res.Fields
> Print "Found field: " & resF.Name
> Next
> Print "Result Count: " & res.Count
> res.MoveFirst
> Print "Available? " & boolToString(res.Available)
> While res.Available
> res.MoveNext
> Print "Field1: " & res["Field1"]
> Wend
>
> End
>
> Private Function boolToString(value As Boolean) As String
>
> If value Then
> Return "True"
> Endif
> Return "False"
>
> End
>
> ************ result ***********
> Found field: ID
> Found field: Field1
> Found field: Field2
> Found field: Field3
> Result Count: 0
> Available? False
> ************ result ***********
>
> Many thanks in advance for any new pointers...
>
> Regards,
> Caveat
>
>
> ------------------------------------------------------------------------------
> All of the data generated in your IT infrastructure is seriously valuable.
> Why? It contains a definitive record of application performance, security
> threats, fraudulent activity, and more. Splunk takes this data and makes
> sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-d2d-c2
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
--
Fabien Bodard
More information about the User
mailing list