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?
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.
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.