QString insertStatement
= driver
->sqlStatement
(QSqlDriver::InsertStatement,
"testTbl",rec,
true);
QString selectStatement
= driver
->sqlStatement
(QSqlDriver::SelectStatement,
"testTbl",rec,
true);
QString updateStatement
= driver
->sqlStatement
(QSqlDriver::UpdateStatement,
"testTbl",rec,
true);
QString deleteStatement
= driver
->sqlStatement
(QSqlDriver::DeleteStatement,
"testTbl",rec,
true);
QString whereStatement
= driver
->sqlStatement
(QSqlDriver::WhereStatement,
"testTbl",rec,
true);
qDebug() << " Insertstatement " << insertStatement << endl;
qDebug() << " Selectstatement " << selectStatement << endl;
qDebug() << " Updatestatement " << updateStatement << endl;
qDebug() << " Deletestatement " << deleteStatement << endl;
qDebug() << " Wheretstatement " << whereStatement << endl;
QSqlQuery query;
QSqlDriver const * driver = query.driver();
QSqlRecord rec = driver->record("testTbl");
QString insertStatement = driver->sqlStatement(QSqlDriver::InsertStatement,"testTbl",rec,true);
QString selectStatement = driver->sqlStatement(QSqlDriver::SelectStatement,"testTbl",rec,true);
QString updateStatement = driver->sqlStatement(QSqlDriver::UpdateStatement,"testTbl",rec,true);
QString deleteStatement = driver->sqlStatement(QSqlDriver::DeleteStatement,"testTbl",rec,true);
QString whereStatement = driver->sqlStatement(QSqlDriver::WhereStatement,"testTbl",rec,true);
qDebug() << " Insertstatement " << insertStatement << endl;
qDebug() << " Selectstatement " << selectStatement << endl;
qDebug() << " Updatestatement " << updateStatement << endl;
qDebug() << " Deletestatement " << deleteStatement << endl;
qDebug() << " Wheretstatement " << whereStatement << endl;
To copy to clipboard, switch view to plain text mode
if(!query.exec("INSERT INTO testTbl VALUES (10,20)"))
{
qDebug() << query.lastError().text();
return false;
}
QString executedQuery
(query.
executedQuery());
qDebug() << "executed query " << executedQuery << endl;
if(!query.exec("INSERT INTO testTbl VALUES (10,20)"))
{
qDebug() << query.lastError().text();
return false;
}
QString executedQuery(query.executedQuery());
qDebug() << "executed query " << executedQuery << endl;
To copy to clipboard, switch view to plain text mode
Bookmarks