I think your right scott. If I change back to RealSQLDatabase all works ok but when
I run my program with the new SQLiteDatabase I get a program error of:
Program Database Error: 0
RecordSet is not editable because no primary key exist.
Ahh THAT error. Using the REALSQLDatabase you didn’t have to define a primary key for your table. If you didn’t have a PK, RealBasic would use the rowid as the PK for you. Which is not best practices as rowid can change on you. Now with SQLiteDatabase, they for you to define a PK for each table. Good news is SQLite will use your PK as the rowid if a PK is defined.
[quote=11782:@Nedi Freguglia]Scott, have you any suggestion for my problem?
Thanks[/quote]
I would make sure every place you reference the data from the SQLiteDB, make sure you reference the PK also. So if you are making a new RecordSet (new records), make sure for every record, you have defined the PK (either the rowid or the one you defined). Every select needs to have the PK as one of the fields (if using rowid, you must manually/explicitly call it out). The PK is how the database delineates from one row to another.
I have a table with 3 columns as primary key: year (integer), invoicenum (text), linenum (integer). I read a record from this table using a SQL statement (select * from rigven where year = 2013 and invoicenum = ‘10/13’ and linenum = 20) setting up a recordset. The code changes the values of some columns and then updates the recordset (recordset.edit recordset.update). With RealSQLDatabase this works fine, with SQLiteDatabase the same code updates all the records that have year = 2013. I cannot understand why.
Thank you, Tim. This is perhaps the reason why the update involved all the records of the same Year: only the first column (an integer value) is considered the primary key.
I’ll modify the primary key and try again.
Thank you again.