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. #5
    Join Date
    Aug 2013
    Posts
    13
    Qt products
    Qt5
    Thanks
    2

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

    Here is widget.h
    Qt Code:
    1. #ifndef WIDGET_H
    2. #define WIDGET_H
    3.  
    4. #include <QWidget>
    5. #include <QtSql/QSqlDatabase>
    6. #include <QSqlError>
    7. #include <QSqlQuery>
    8. #include <QStringList>
    9.  
    10. namespace Ui {
    11. class Widget;
    12. }
    13.  
    14. class Widget : public QWidget
    15. {
    16. Q_OBJECT
    17.  
    18. public:
    19. explicit Widget(QWidget *parent = 0);
    20. ~Widget();
    21.  
    22. public:
    23. QString vrijeme;
    24. QString vrijemeKraj;
    25. QSqlQuery sqlTrazi;
    26.  
    27.  
    28. bool conOpen(){
    29.  
    30. QSqlDatabase db=QSqlDatabase::addDatabase("QODBC");
    31.  
    32. db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=D:/Programi/SynSetup/Synesis/Pupilla.mdb");
    33.  
    34. if(!db.open())
    35. {
    36.  
    37. //qDebug() << "Database Error" << db.lastError(); //<< db.lastError().text();
    38.  
    39. return false;
    40.  
    41. }
    42.  
    43. else
    44.  
    45. {
    46. return true;
    47. }
    48.  
    49. }
    50.  
    51.  
    52.  
    53. void closeConnection(){
    54. db.close();
    55. }
    56.  
    57. private:
    58. Ui::Widget *ui;
    59. };
    60.  
    61. #endif // WIDGET_H
    To copy to clipboard, switch view to plain text mode 
    Last edited by anda_skoa; 6th March 2016 at 16:16. 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
  •  
Qt is a trademark of The Qt Company.