GoranSimunic
8th March 2016, 14:58
Hi to all,
do you have a clue why counting 190 tables in mdb lasts for over a minute and half,
and time to closing connection lasts almost 2 minutes from reading the tables?
mdb file which is read is 120 megs!
this is part of code,
.cpp and .h file attached...
QStringList list = db.tables(QSql::Tables);
//qDebug() << "Views list\n " << list.join(",").toLocal8Bit().data() << "\n";
qDebug() << list.count();
if(db.tables().isEmpty()){
qDebug() << "list empty ";
}
else {
qDebug() << "list not empty";
}
.h file
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QtSql/QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
#include <QStringList>
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
public:
QString vrijeme;
QString vrijemeKraj;
QSqlDatabase db;
QSqlQuery sqlTrazi;
QStringList list;
bool conOpen(){
db=QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=D:/Instalacija/syn/Storage.mdb");
if(!db.open())
{
//qDebug() << "Database Error" << db.lastError(); //<< db.lastError().text();
return false;
}
else
{
return true;
}
}
void closeConnection(){
db.close();
}
private:
Ui::Widget *ui;
//QSqlDatabase db;
};
#endif // WIDGET_H
.cpp file
#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QTime>
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
qDebug() << QSqlDatabase::drivers();
QVector<QString> lista; //this is not used at the moment
if(!conOpen()){
qDebug() << "konekcija nije uspjela " << "\n"; //not connected
}
else {
qDebug() << "konekcija je uspješna"; //connected...
}
vrijeme = QTime::currentTime().toString("hh:mm:ss:zzz");
qDebug() << vrijeme << "\n";
QStringList list = db.tables(QSql::Tables);
qDebug() << list.count();
if(db.tables().isEmpty()){
qDebug() << "list empty - lista je prazna";
}
else {
qDebug() << "list not empty - Lista nije prazna?";
}
Widget::closeConnection();
vrijemeKraj = QTime::currentTime().toString("hh:mm:ss:zzz");
qDebug() << vrijemeKraj << "\n";
qDebug() << "connection closed-konekcija zatvorena ";
}
Widget::~Widget()
{
delete ui;
}
do you have a clue why counting 190 tables in mdb lasts for over a minute and half,
and time to closing connection lasts almost 2 minutes from reading the tables?
mdb file which is read is 120 megs!
this is part of code,
.cpp and .h file attached...
QStringList list = db.tables(QSql::Tables);
//qDebug() << "Views list\n " << list.join(",").toLocal8Bit().data() << "\n";
qDebug() << list.count();
if(db.tables().isEmpty()){
qDebug() << "list empty ";
}
else {
qDebug() << "list not empty";
}
.h file
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QtSql/QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
#include <QStringList>
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
public:
QString vrijeme;
QString vrijemeKraj;
QSqlDatabase db;
QSqlQuery sqlTrazi;
QStringList list;
bool conOpen(){
db=QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=D:/Instalacija/syn/Storage.mdb");
if(!db.open())
{
//qDebug() << "Database Error" << db.lastError(); //<< db.lastError().text();
return false;
}
else
{
return true;
}
}
void closeConnection(){
db.close();
}
private:
Ui::Widget *ui;
//QSqlDatabase db;
};
#endif // WIDGET_H
.cpp file
#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QTime>
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
qDebug() << QSqlDatabase::drivers();
QVector<QString> lista; //this is not used at the moment
if(!conOpen()){
qDebug() << "konekcija nije uspjela " << "\n"; //not connected
}
else {
qDebug() << "konekcija je uspješna"; //connected...
}
vrijeme = QTime::currentTime().toString("hh:mm:ss:zzz");
qDebug() << vrijeme << "\n";
QStringList list = db.tables(QSql::Tables);
qDebug() << list.count();
if(db.tables().isEmpty()){
qDebug() << "list empty - lista je prazna";
}
else {
qDebug() << "list not empty - Lista nije prazna?";
}
Widget::closeConnection();
vrijemeKraj = QTime::currentTime().toString("hh:mm:ss:zzz");
qDebug() << vrijemeKraj << "\n";
qDebug() << "connection closed-konekcija zatvorena ";
}
Widget::~Widget()
{
delete ui;
}