Qt应用程序中的"No query Unable to fetch row"
"No query Unable to fetch row" in Qt app
我在Qt 5.9中使用数据库创建一个表sqlite
但收到此错误:
无查询 无法提取行
QSqlQuery query("create table credit(username text primary key, password text);");
if(!query.exec())
{
ui->result->append("dataentry unsuccessful...n"+query.lastError().text()+"n");
}
else
{
ui->result->append("looks good...");
}
两件事:
-
DDL 语句可以在 QSqlQuery 中使用。但是没有必要在
"create table credit(username text primary key, password text);"
末尾添加分号(;) -
其次,当您创建以查询字符串作为参数的 QSqlQuery 对象时,它会立即执行它。没有必要打电话给
query.exec()
.
您可以将exec()
替换为isValid()
方法,以检查条件中查询的有效性。
希望这有帮助。
相关文章:
- "Unable to start debugging. No process is associated with this object." - 在Visual Studio Code中使用GDB
- Win32 API - HWND "{unused = ???} Unable to read memory"错误
- 从生成文件编译错误:"Unable to open output file" ..."No such file or directory"
- 如何在qt中修复"No query Unable to fetch row"
- 类型字符串::长度()。我得到了"Unable to resolve identifier length"
- Qt应用程序中的"No query Unable to fetch row"
- 如何处理"Cmake Error: Unable to find the requested Boost libraries"?
- MSVC:带函数的"error C2244: unable to match function definition to an existing declaration"是指专用模板类的类型别名
- 使用 Korge 编译本机时"Unable to find library"抛出错误
- QNetwork回复 "unable to write"
- AWS 批处理"unable to connect to endpoint"
- 仅在一台计算机上出现"0xc000007b Application Unable to Start Correctly"错误
- "Unable to open file libc++abi.dylib" .程序生成,但在运行时崩溃。使用 xcode 10.1 (10B61)
- 调用 QSqlTableModel setTable 方法时出现"Unable to find table"错误
- 为什么 void 排序(int *[], int) 会导致"Unable to read memory"?
- 如何设置Visual Studio来调试DLL ("Unable to start program error")
- PCC-S-02015, "unable to open include file"
- 在 exiv2 中"unable to parse" IPTC 日期到 XMP 日期时间
- "Unable to resolve template based identifier X" - 从模板类调用模板参数类的方法 (C++)
- AWS S3 aws-sdk-cpp GetObject "Unable to connect to endpoint"