MySQL MovePrevious alternative

Hi guys.
I have been trying to create part of an application which allows the users to cycle through records.
I have managed to get something working using recordsets and i quickly learned that only r.movenext works with MySQL.

Does anyone know an alternative? I need to be able to select the next, previous, first and last record in the sql query.

The alternative is to do it yourself. Request all the primary keys in the order you want and then store them in an array. Move through the array as necessary and then use the PrimaryKey to do another SQLSelect to fetch the data.

Of course, if it is not a lot of data, you could just loop through the RecordSet and load all the data into a class that represents that table and store that in an array.

Thanks for the reply. Sorry for not responding, i have been on holiday :slight_smile:
Can you, or anyone provide an example? I havent been using Xojo very long and i never used realbasic.
Thanks

Something like this ought to work (not tested):

[code]Dim rs As RecordSet
rs = myDB.SQLSelect(“SELECT ID FROM MyTable”)

Dim tableID() As Integer // Array of primary keys in MyTable
While Not rs.EOF
tableID.Append(rs.IdxField(1).IntegerValue)
rs.MoveNext
Wend
rs.Close

// Use the array to get a primary key and use that to fetch the table data
Dim stmt As PreparedSQLStatement
stmt = myDB.Prepare(“SELECT * FROM MyTable WHERE ID = ?”)
stmt.BindType(0, SQLitePreparedStatement.SQLITE_INTEGER)
stmt.Bind(0, tableID(22)) // Or whatever record you want from the array

Dim data As RecordSet
data = stmt.SQLSelect

Dim value As String
value = data.Field(“MyColumn”).StringValue[/code]