recordset empty

I have a class with methods and properties
One of the properties is rs = recordset (public)

if rs <> nil Then dim m8 As String while not rs.EOF dim m9(-1) As string for fld as Integer = 0 to UBound(aFldnumbers) m8 = rs.IdxField(.... m9.Append ..... next w.Listbox1.AddRow(m9) rs.MoveNext wend end If rs.MoveFirst
The listbox1 fills okay.
At this point I debug and read rs
There is nothing, … empty
Why is this?

Maybe your database doesn’t support rs.MoveFirst. What database are you using?

Most of the databases don’t support MoveFirst so you’ll have to require or put the data in an intermediate form for reuse.

According to the docs at http://documentation.xojo.com/index.php/RecordSet.MoveFirst only SQLite, Oracle, and some ODBC Databases support it.

[h]Database = Mysql[/h]

What am I trying to do:
We have:
myClass with
Methods

  • readData
  • fillListBox ( Populate the listbox of window1 and remembers the recordset rs)
  • handlerClickLineOfListbox (*)
    Properties
  • rs (recordset)

Window1 with
Listbox1
eventdefinition connecting to handlerClickLineOfListbox (*)

What is done:
I click on a line of the listbox
this passes through the handlerClickLineOfListbox where I like to read the recordset rs
Like:

rs.MoveFirst dim c As integer = rs.RecordCount dim r As string for i as Integer = 0 to c 'r = rs.IdxField(14).StringValue r = rs.field("ba_nummer").StringValue rs.MoveNext next
c=40
but
r stays empty (in both ways, idxfield or field)

If I put the same at the in the method ‘fillListBox’
I have the same result.
I must be overlooking something

MySQL does not support MoveFirst, and keeping a RecordSet around is considered bad practice anyway.

You should consider copying the data to some class object. Bob Keeney’s ActiveRecord, among others, will help you do this so you end up storing an object that represents the record with the Listbox. In this scenario, rs would be a method variable rather than a property and handlerClickLineOfListbox would pull the object out of the Listbox row’s RowTag.

It is quite unbelievable that a database like MySQL can’t do Movefirst.

So what you 're suggesting is that I store the record as a tag in the ListBox
There are two ways

  1. put the record in a DatabaseRecord
  2. as a string

dim valuesOfRow() As string for i as Integer=0 to me.ColumnCount - 1 valuesOfRow.Append me.Cell(row,i) next returnRecord = Join(valuesOfRow,";")
I only use strings in a database
Is there another way?

Yes, and I mentioned it in my post.

The only other way I can read in your post is the Bob Keeney’s ActiveRecord.

I downloaded it a time ago and at that time I did not understand it.
Maybe I have to try to understand it once again.
But I think I can’t use it because in my applications, every table has its definitions stored in a parameter table.
Tables are read, written and updated with different classes I wrote, which use this parameter files/tables.

Thank you for your time

Kem’s right, avoid it like the plague. In our old VB6 code we had a habit of doing that for performance reasons, and I wish I had a nickel for every time it bit us in the rear. When we ported it over to Xojo 5 years ago, we got rid of that practice right from the start.

I accept this and thank you for the advice.

Because all the fields of the record in the table are strings, I put now all fields in an array which is stored as a rowTag in the Listbox. I hope there is nothing wrong with this.

Again Thanks everybody.