我正在对SQLite数据库使用更新查询,但一直收到此错误,我无法理解我哪里出错了。Failed QSqlError("", "Unable to fetch row", "No query")
这就是我创建表格的方式。
CREATE TABLE IF NOT EXISTS singleSetting (set_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, date DATETIME,"
"password VARCHAR(255), unique_column VARCHAR(2) UNIQUE, logo BLOB, title VARCHAR(50), print_dialog INTEGER(1),"
"staffImageDir VARCHAR(255),visitorImageDir VARCHAR(255),camera INTEGER(1),host VARCHAR(50),database VARCHAR(50),"
"username VARCHAR(50),pass VARCHAR(50),port INTEGER(10));
我的代码,我尝试将端口转换为QString,但这也不起作用。
QString host = ui->lineEdit_host->text();
QString database = ui->lineEdit_database->text();
QString username = ui->lineEdit_username->text();
QString password = ui->lineEdit_password->text();
int port = ui->lineEdit_port->text().toInt();
//QString p = QString::number(port);
QSqlQuery qry;
qry.prepare( "UPDATE singleSetting SET host = '"+host+"', "
"database = '"+database+"', username = '"+username+"', "
"pass = '"+password+"',port = '"+port+"' WHERE unique_column = '0'" );
if( !qry.exec() )
{
qDebug() <<"Failed "<< qry.lastError();
}else{
qDebug() <<"Success";
}