Dear all,
what am I doing wrong in trying to get QString list of all tables in mdb file.
Im getting printed records from *mdb file, from table called labels, (there are two more empty tables in this file),
but list name returns me an empty list?
here is just .cpp
#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QTime>
ui(new Ui::Widget)
{
ui->setupUi(this);
if(!conOpen()){
qDebug() << "not connected " << "\n";
else {
qDebug() << "connected...";
}
vrijeme
= QTime::currentTime().
toString("hh:mm:ss:zzz");
qDebug() << vrijeme << "\n";
if(sqlTrazi.exec("select * from labels")){
while(sqlTrazi.next()){
qDebug() << sqlTrazi.value(0).toString() << " " << sqlTrazi.value(1).toString() ;
}
}
qDebug() << "Views list\n " << list.join(",").toLocal8Bit().data() << "\n";
if(db.tables().isEmpty()){
qDebug() << "list empty - lista je prazna";
}
else {
qDebug() << "list not empty";
}
Widget::closeConnection();
vrijemeKraj
= QTime::currentTime().
toString("hh:mm:ss:zzz");
qDebug() << vrijemeKraj << "\n";
qDebug() << "connection closed ";
}
Widget::~Widget()
{
delete ui;
}
#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();
if(!conOpen()){
qDebug() << "not connected " << "\n";
else {
qDebug() << "connected...";
}
vrijeme = QTime::currentTime().toString("hh:mm:ss:zzz");
qDebug() << vrijeme << "\n";
QSqlQuery sqlTrazi;
if(sqlTrazi.exec("select * from labels")){
while(sqlTrazi.next()){
qDebug() << sqlTrazi.value(0).toString() << " " << sqlTrazi.value(1).toString() ;
}
}
QStringList list = db.tables(QSql::AllTables);
qDebug() << "Views list\n " << list.join(",").toLocal8Bit().data() << "\n";
if(db.tables().isEmpty()){
qDebug() << "list empty - lista je prazna";
}
else {
qDebug() << "list not empty";
}
Widget::closeConnection();
vrijemeKraj = QTime::currentTime().toString("hh:mm:ss:zzz");
qDebug() << vrijemeKraj << "\n";
qDebug() << "connection closed ";
}
Widget::~Widget()
{
delete ui;
}
To copy to clipboard, switch view to plain text mode
Bookmarks