I’m working on some old Real Studio code and upgraded my database type from realSQLdatabase to SQLiteDatabase.
When I update a recordset it only updates if I select the entire row of the table.
Is this a difference between the two database formats?
This works:
Dim pstrSQL as string = "SELECT * FROM tblPictures WHERE nameId = '" + A.id + "'"
Dim rs as RecordSet = db.SQLSelect(pstrSQL)
rs.Edit
rs.Field(fieldname).Value = 0
rs.update
db.Commit
This doesn’t:
Dim pstrSQL as string = "SELECT fieldname FROM tblPictures WHERE nameId = '" + A.id + "'"
Dim rs as RecordSet = db.SQLSelect(pstrSQL)
rs.Edit
rs.Field(fieldname).Value = 0
rs.update
db.Commit
Code is a simple illustration (please no lectures about using prepared statements).
Check the Error property after this call. If the record could not be updated then Error will be True. You can then display the error message using the ErrorMessage property.
Some databases do not allow you to update if the SQL statement used to get the RecordSet contains more than one table. Additionally, some databases may require that the SQL statement specifically include the Primary Key for the table. [/quote]