Help with using a RecordSet property


I’m using SQLite and I’m having problems with something.
Basically on a Window’s ‘Open’ event I assign a RecordSet property a record that I get from a table.
In a Method, ‘UpdateRecord’, I want to update the record in the table using the RecordSet property but I get this error:
The current row in the RecordSet is not editable (out of range).

Here is the code:

'logRecord is the RecordSet property logRecord.Edit Dim i As Integer Dim obj As Control Dim count As Integer = Self.ControlCount - 1 For i = 0 To count obj = Self.Control(i) if obj IsA TextField then Dim tf As TextField=TextField(obj) Dim field As String=Right(tf.Name,tf.Name.Len-3) logRecord.Field(field).Value=tf.Text end next logRecord.Update if not gDatabase.Error then gDatabase.Commit else MsgBox("Error when updating: "+gDatabase.ErrorMessage) end

It would work with a record straight from a table but it doesn’t work when I use the RecordSet property; how do I connect the record property back to the database?

Thank you.

Are you dimming logRecord within ths same method? If not, then it’s out of scope.
Have you assigned values to your recordSet using SQL statements. If so, please show that code.

I don’t know how to do that? Could you explain please?

Dim record As RecordSet record=gDatabase.SQLSelect("SELECT * From Training") if record<>nil then record.MoveFirst while not record.EOF {conditionals} logRecord=record

I’ve not done this before so I’m not sure what I am meant to do.


Does your table has a primary key?

Yes, ‘RunnerID’?

Once you hit record.EOF, you no longer have a valid record.

Rami, I would suggest taking a look at the database examples which come with the Xojo download. Trying to learn the basics by posting here and receiving terse replies can be very frustrating. There s also example DB code on several Xojo related sites. Good luck.

I have got it to work by simply not saving the record to a RecordSet property; I just looked the record again elsewhere and it works.

Thanks for all your help!

We have a number of videos (and project files) showing database code (both regular Xojo and ActiveRecord) at