AMP1M = 1652.90 ANG_H = Azim ANG_V = 49.6 ANT_REZ = 0.0APERT1 = 3805 8 0.000084APERT2 = 11313 8 0.000028AZ1 = 67.05AZ2 = 68.30BOARD = LEFTBORDER = 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
void QDbfReader::openDBF(QString dbfName){QSqlDatabase dbs = QSqlDatabase::addDatabase("QIBASE"); dbs.setDatabaseName("c:\\database.fdb"); dbs.setUserName("sysdba"); dbs.setPassword("masterkey"); QStringList dbList = QSqlDatabase::drivers(); bool _is_open= dbs.open(); QStringList tList = dbs.tables(); QSqlQuery statement(dbs); QString error; QString createQuery; if (!tList.contains("baseTable", Qt::CaseInsensitive)) { QMapIterator<QString, QString> iterator(allFields); createQuery = "create table basetable ( p_key bigint NOT NULL PRIMARY KEY, dbfName varchar(50), "; while(iterator.hasNext()) { iterator.next(); createQuery+= "\"" + iterator.key() + "\"" + " varchar(100), "; } createQuery.replace(createQuery.lastIndexOf(","), 1, ")"); dbs.transaction(); statement.exec(createQuery); error = statement.lastError().text(); dbs.commit(); } if (!tList.contains("fieldsTable", Qt::CaseInsensitive)) { createQuery = "create table fieldsItems ( "; QMapIterator<QString, QString> iterator(allFields); while(iterator.hasNext()) { iterator.next(); createQuery+= "\"" + iterator.key() + "\"" + " varchar(50), "; } createQuery.replace(createQuery.lastIndexOf(","), 1, ")"); dbs.transaction(); statement.exec(createQuery); error = statement.lastError().text(); dbs.commit(); } //insertion QString insertionQuery = "INSERT INTO baseTable (p_key, dbfName, "; QMapIterator<QString, QString> iterator(allFields); while(iterator.hasNext()) { iterator.next(); insertionQuery+= "\"" + iterator.key() + "\", "; } insertionQuery.replace(insertionQuery.lastIndexOf(","), 2, ") "); insertionQuery+= "VALUES (" + p_key + ", '" + dateInfo.baseName() + "', "; iterator.toFront(); while(iterator.hasNext()) { iterator.next(); insertionQuery+= "'" + iterator.value() + "'" + ", "; } insertionQuery.replace(insertionQuery.lastIndexOf(","), 2, ") "); query_to_file(insertionQuery); dbs.transaction(); statement.exec(insertionQuery); error = statement.lastError().text(); dbs.commit(); file.close(); //dbs.close();}
void QDbfReader::query_to_file (QString query){ QFile file_stream("d:\\dbf\\out.txt"); QTextStream stream(&file_stream); file_stream.open(QFile::WriteOnly); stream << query; file_stream.close();}