c++ - Subsequent insertion of records with QSqlTableRecord fail after first error -


I have problems inserting data into SQLite database by using QSqlTableModel. The table is created like this:

  QSqlQuery createTblSMS ("Create table sms_tbl (" "Reed bullion tap," "Reditime datite," "Outtime datetime faucet," "Sender text not faucet," "Receiver text tap," "SMS Content text, "" primary key (arrival time, sender, receiver)) ";);  

I am including this type of archive:

  smsModel-> InsertRecord (-1, sms); QString Error = smsModel-> Last error (). Text (); SmsModel- & gt; SubmitAll ();  

SMS modal is QSqlTableModel

If I put a value for example then this value (false, zero, '2010-06-30 17:27:55 ',' 075710383 ',' A142140 ',' Top 15 # 2 ') - Record is inserted. For example, if this record is placed after this record (false, zero, '2010-06-30 10:05:29', '075710383', 'one 142140', 'top 15 # 3') - this The record is also inserted.

But if I try to rejoin the record (wrong, tap, '2010-06-30 17:27:55', '075710383', 'one 142140', 'Top 15 # 2 Do ') which is already in the database, the SMS MODEL will give an error like this: "column arrival time, sender, receivers are not unique" unable to get the line - which is expected. Any other subsequent insertions of unique records will fail and the model gives me the same error. Do you have any clue why this is happening?

I went into this issue of two times.

When you are in manual deposit mode, QSqlTableModel does not clean its cache once a subfix fails (this should be done when you send it a record that violates your barriers).

To fix this, you must call the call to remove those pending changes () or call back to return.

Doctors do not make it very clear, but it is there, see:


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -