在TQ2440上运行SQLite3测试程序时遇到下面的
问题:
QSqlError(14, "Unable to fetch row", "unable to open database file")
我
数据库可以打开,可以查询,但是就是不能更改。同样的程序在PC机上就能够运行,交叉
编译后放到板子上就会报错,请高手指点。
- int main(int argc, char *argv[])
- {
- QApplication app(argc,argv);
- QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
- db.setDatabaseName("/mnt/sd/data.db");
- if(!db.open())
- {
- std::cout <<"the Database: data.db cannot open"<<std::endl;
- QMessageBox::warning(0, QObject::tr("Database Error"),
- db.lastError().text());
- }
- QSqlTableModel model;
- model.setTable("pressure");
- model.setEditStrategy(QSqlTableModel::OnManualSubmit);
- model.select();
- int row = model.rowCount();
- qDebug() <<row;
- if(!model.removeRows(0,2))
- qDebug() << model.lastError();
- if(true==model.submitAll())
- {
- printf("model sucessfule!!!\n");
- }
- else
- {
- printf("model error!!!\n");
- qDebug() << model.lastError();
- }
- QPushButton *hello = new QPushButton;
- hello->setText("Hello Qt!!");
- hello->show();
- return app.exec();
- }