SQLite: how to modify a record


to modify a given Record, we have to set its Unique ID.

This is not possible to do using a DatabaseRecord.

Any idea ?

DatabaseRecord is used for inserting new rows only. From the docs:

Used to create new Database records (rows).[/quote]

And so I have to check by myself the passed Colum contents watching about '…

First you need to read the record into a RecordSet. Then use the RecordSet Edit capability to edit the data. Then Update the RecordSet. This does require that the table have a primary key defined.

[code] sql ="SELECT * FROM myTable WHERE ID = " + Str(CurrentID)
rs = theDB.SQLSelect(sql )
// Update the data on the record
rs.Field(“WebAddr”).StringValue = tfWebSite.Text ’ WebAddr is the field to be edited

// Update the record in the database
if theDB.Error then ' Do some cleanup on errors
  ' DisplayDatabaseError true
  if rs <> nil then
  end if
end if
// Commit changes to the database


This is off the top of my head so there might be errors in it but the general approach works. And, of course, there are other way to do it but this works for me.