[Interest] InsertRecord/SQLite bug?
Guido Seifert
wargand at gmx.de
Mon Mar 2 14:33:01 CET 2015
Hi,
I discovered that some ancient code stopped working. Don't know when this actually happened. Maybe when I ported it from qt4 to qt5
ages ago.
The problem:
I have a sqlite table:
CREATE TABLE IF NOT EXISTS searchdir(
selected INT DEFAULT 0,
directory TEXT NOT NULL UNIQUE
);
I have code, which is supposed to enter data:
void SearchFolderSelectionForm::addSlt(void){
QString dir = QFileDialog::getExistingDirectory(this,tr("Add search Folder"),
tr("Add search folder"));
QSqlRecord record;
{
QSqlField field("directory",QVariant::String);
field.setValue(dir);
record.append(field);
}
{
QSqlField field("selected",QVariant::Int);
field.setValue(0);
record.append(field);
}
if(!_searchDirModel->insertRecord(0,record)){
qDebug() << _searchDirModel->lastError();
}
}
I get an error:
QSqlError("", "No Fields to update", "")
Strange thing is, I can add data manually into this table. But if I then execute above function,
the data is not inserted, but row 0 is deleted from the db.
Anyone an idea? Above code definitely worked once.
Guido
More information about the Interest
mailing list