QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");db.setDatabaseName("DRIVER={SQL...}");QSqlDatabase::database().open();
QSqlQueryModel *qModel = new QSqlQueryModel();qModel->setQuery("SELECT * FROM TABLE X");
QSqlDatabase::database ().transaction ();qModel->setQuery(querystring);QSqlDatabase::database ().commit();
C++ (Qt)QSqlQueryModel *qModel = new QSqlQueryModel(this);
C++ (Qt)qModel = new QSqlQueryModel(this);
QSqlQueryModel * ADatabase::selectSql(QString querystring) { qModel->setQuery(querystring); if (qModel->lastError().isValid()) { qDebug() << qModel->lastError(); qDebug() << "SQL code:" << querystring; } while (qModel->canFetchMore()) { qModel->fetchMore(); } return qModel;}