QSqlQuery query(QSqlDatabase::database());query.prepare("SELECT id, checknumber FROM 'p_tovar' WHERE 'p_tovar'.'schkod' = :schkod");query.bindValue(":schkod", value);if(!query.exec()){ QApplication::beep(); QMessageBox::critical(this, QObject::tr("SQL Error"), query.lastError().text()); return;}
sqlite> .tablesp_check p_kamen p_tovarsqlite>
sqlite> SELECT id, checknumber FROM 'p_tovar' WHERE 'p_tovar'.'schkod' = '2900000113';1|
QString sql(QString("SELECT id, checknumber FROM p_tovar WHERE p_tovar.schkod = %1").arg(value));QSqlQuery query(sql, QSqlDatabase::database());
QSqlDatabase db = QSqlDatabase::addDatabase( ParameterSQL.DriverName ); db.setDatabaseName( ParameterSQL.DatabaseName ); if (ParameterSQL.DriverName != "QSQLITE") { db.setHostName( ParameterSQL.HostName ); db.setPort( ParameterSQL.PortNumber ); db.setUserName( ParameterSQL.UserName ); if ( ParameterSQL.SavePasword ) db.setPassword( ParameterSQL.Password ); } if ( !db.open() ) { listBrowseMessage(QString::fromUtf8("Не удалось подключиться к локальной базе данных.")); } if (db.isValid()) MainWindowImpl::showTableWidget(); else qDebug() << TEXTLOGING << "db.isValid = " << db.isValid();
C++ (Qt)...QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");db.setDatabaseName("mydatabase");if (!db.open()) return;QSqlQuery query;query.prepare("SELECT id, checknumber FROM p_tovar WHERE p_tovar.schkod = ?");query.addBindValue(myValue);if (!query.exec()) return;...