СREATE TABLE d__190710_163135L ( id_d__190710_163135L integer primary key autoincrement,INDX text,NAME text,MAX text,SUMMA text,POWER text,MSE text);CREATE TABLE s__190710_163135L ( id_s__190710_163135L integer primary key autoincrement, fieldName text, fieldType text, fieldLength numeric, fieldDecimals numeric);
void QDbfReader::sql_execute(QString query){ model->setQuery(query, QSqlDatabase::database("dbfEditor")); align_view(); view->setModel(model);}
..............................QSqlQuery q(QSqlDatabase::database("dbfEditor")); q.prepare(dropQuery); q.exec(); if (q.lastError().isValid()) { QMessageBox::critical(this, tr("Error"), q.lastError().text()); return; } q.prepare(createQuery); q.exec(); if (q.lastError().isValid()) { QMessageBox::critical(this, tr("Error"), q.lastError().text()); return; } q.prepare(insertQuery); q.exec(); if (q.lastError().isValid()) { QMessageBox::critical(this, tr("Error"), q.lastError().text()); return; }..................................
DROP TABLE IF EXISTS d__190710_163547L; DROP TABLE IF EXISTS s__190710_163547L;DROP TABLE IF EXISTS d__190710_164044L; DROP TABLE IF EXISTS s__190710_164044L;DROP TABLE IF EXISTS d__190710_164526L; DROP TABLE IF EXISTS s__190710_164526L;DROP TABLE IF EXISTS d__190710_165002L; DROP TABLE IF EXISTS s__190710_165002L;DROP TABLE IF EXISTS d__190710_165407L; DROP TABLE IF EXISTS s__190710_165407L;
void openDBF(QString name){...........................................................................QSqlQuery getData(QSqlDatabase::database("dbfEditor")); query = "DROP TABLE IF EXISTS "; query += tableName; getData.prepare(query); getData.exec();}
QSqlDatabase dbase = QSqlDatabase::database("dbfEditor"); dbase.setDatabaseName(dbFile); if (!dbase.open()) { QMessageBox::warning(0, QString::fromLocal8Bit("Ошибка"), QString::fromLocal8Bit("Ошибка при подключении к базе данных %1.").arg(dbFile)); return; } dbase.transaction(); QSqlQuery getData(dbase);//here go queries............ dbase.commit();