Qt不能在sqlite3中创建表
can not make a table in sqlite3 by Qt
我已经用这个命令在终端中创建了一个数据库:
sqlite3 test.db
然后我试着用这些代码制作一个表:
ui->setupUi(this);
db1.setDatabaseName("test.db");
bool k=db1.open();
QSqlQuery q(db1);
q.prepare("CREATE TABLE by_code(id INT)");
q.exec();
qDebug()<<"isOpen: "<<k<<" Error:"<<q.lastError();
输出为:
isOpen: true Error: QSqlError(-1, "Unable to fetch row", "No query")
有什么问题,我该如何解决? Qt试图获得查询的结果,但CREATE TABLE
语句不返回结果。
不被认为是实际错误。查询是否成功,可查看exec
函数的返回值
相关文章:
- 如何创建一个CMake变量,除非显式重写,否则使用默认值
- 使用std::multimap迭代器创建std::list
- 在全局变量中保存类的实例以重新创建类(创建"backup")
- 使用CMake创建QML插件
- 如何在c++中为模板函数实例创建快捷方式
- 在C++中,是否可以基于给定的标识符创建基类的新实例,反之亦然
- 创建一个函数以在输入为负数或零时输出字符串.第一次执行用户定义的函数
- OpenCV EqualizeHist()从彩色图像创建黑白图像
- 试图在visual studio上用C++创建一个桌面应用程序
- std::threads可以从Windows DLL中的全局变量创建/销毁吗?
- 如何在C++20中创建模板别名的推导指南
- 如何为模板化对象创建模板向量?VS正在投掷C3203
- 如何创建一个空的全局类并在启动时实例化它
- 无法创建抽象类的实例
- 链接到自行创建的dll失败
- 需要为SQLite3数据库创建索引(索引)
- C 中的sqlite3创建语句和外键
- 通过在Sqlite3数据库C++中获取表来创建对象
- Qt不能在sqlite3中创建表
- 创建sqlite3.在Visual studio中使用sqlite3