Results 1 to 7 of 7

Thread: Access mdb file - cant get list of tables or views with db.tables() list

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2013
    Posts
    13
    Thanks
    2
    Qt products
    Qt5

    Default Access mdb file - cant get list of tables or views with db.tables() list

    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
    Qt Code:
    1. #include "widget.h"
    2. #include "ui_widget.h"
    3. #include <QDebug>
    4. #include <QTime>
    5.  
    6. Widget::Widget(QWidget *parent) :
    7. QWidget(parent),
    8. ui(new Ui::Widget)
    9. {
    10. ui->setupUi(this);
    11. qDebug() << QSqlDatabase::drivers();
    12.  
    13.  
    14. if(!conOpen()){
    15. qDebug() << "not connected " << "\n";
    16. else {
    17. qDebug() << "connected...";
    18. }
    19.  
    20. vrijeme = QTime::currentTime().toString("hh:mm:ss:zzz");
    21. qDebug() << vrijeme << "\n";
    22.  
    23. QSqlQuery sqlTrazi;
    24.  
    25. if(sqlTrazi.exec("select * from labels")){
    26. while(sqlTrazi.next()){
    27. qDebug() << sqlTrazi.value(0).toString() << " " << sqlTrazi.value(1).toString() ;
    28. }
    29. }
    30.  
    31. QStringList list = db.tables(QSql::AllTables);
    32. qDebug() << "Views list\n " << list.join(",").toLocal8Bit().data() << "\n";
    33. if(db.tables().isEmpty()){
    34. qDebug() << "list empty - lista je prazna";
    35. }
    36. else {
    37. qDebug() << "list not empty";
    38. }
    39. Widget::closeConnection();
    40. vrijemeKraj = QTime::currentTime().toString("hh:mm:ss:zzz");
    41. qDebug() << vrijemeKraj << "\n";
    42. qDebug() << "connection closed ";
    43.  
    44. }
    45.  
    46. Widget::~Widget()
    47. {
    48. delete ui;
    49. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by anda_skoa; 6th March 2016 at 16:17. Reason: missing [code] tags

Similar Threads

  1. list tables column name (database)
    By baray98 in forum Qt Programming
    Replies: 1
    Last Post: 26th September 2012, 11:18
  2. List of Views for a model
    By gkarthick5 in forum Newbie
    Replies: 3
    Last Post: 23rd June 2011, 08:06
  3. Replies: 4
    Last Post: 13th July 2010, 05:17
  4. Replies: 1
    Last Post: 16th May 2010, 19:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.