• 8249阅读
  • 1回复

QSqlError(14, "Unable to fetch row", "unable to open database file") [复制链接]

上一主题 下一主题
离线紫域风灵
 
只看楼主 倒序阅读 楼主  发表于: 2010-11-21
— 本帖被 XChinux 从 General Qt Programming 移动到本区(2011-01-02) —
在TQ2440上运行SQLite3测试程序时遇到下面的问题
QSqlError(14, "Unable to fetch row", "unable to open database file")
数据可以打开,可以查询,但是就是不能更改。同样的程序在PC机上就能够运行,交叉编译后放到板子上就会报错,请高手指点。
  1. int main(int argc, char *argv[])
  2. {
  3.     QApplication app(argc,argv);
  4.     QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
  5.     db.setDatabaseName("/mnt/sd/data.db");
  6.     if(!db.open())
  7.     {
  8.         std::cout <<"the Database: data.db cannot open"<<std::endl;
  9.         QMessageBox::warning(0, QObject::tr("Database Error"),
  10.                              db.lastError().text());
  11.     }
  12.     QSqlTableModel model;
  13.     model.setTable("pressure");
  14.     model.setEditStrategy(QSqlTableModel::OnManualSubmit);
  15.     model.select();
  16.     int row = model.rowCount();
  17.     qDebug() <<row;
  18.     if(!model.removeRows(0,2))
  19.         qDebug() << model.lastError();
  20.     if(true==model.submitAll())
  21.     {
  22.         printf("model  sucessfule!!!\n");
  23.     }
  24.     else
  25.     {
  26.         printf("model  error!!!\n");
  27.         qDebug() << model.lastError();
  28.     }
  29.     QPushButton *hello = new QPushButton;
  30.     hello->setText("Hello Qt!!");
  31.     hello->show();
  32.     return app.exec();
  33. }
离线紫域风灵
只看该作者 1楼 发表于: 2010-11-22
回 楼主(紫域风灵) 的帖子
问题查出来了,我用的是NFS文件系统,数据库是放在HOST 上的,可能是程序没有权限修改数据库,只能读取,把程序放进yaffs文件系统烧到板子上运行就好了。
快速回复
限100 字节
 
上一个 下一个