Results 1 to 5 of 5

Thread: QODBC by QT

  1. #1
    Join Date
    May 2019
    Posts
    9
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default QODBC by QT

    Hello,

    I've a connection string to ODBC:
    Qt Code:
    1. Provider=ASAProv.90;Persist Security Info=True;User ID=DBA;Data Source=OCONET
    To copy to clipboard, switch view to plain text mode 

    I'm trying to use it by:
    Qt Code:
    1. db = QSqlDatabase::addDatabase("QODBC");
    2. QString connectString = "Provider=ASAProv.90;Persist Security Info=True;User ID=DBA;Data Source=OCONET;";
    3. db.setDatabaseName(connectString);
    4. if(db.open())
    5. {
    6. QMessageBox::about(this,"Connected","Connected");
    7. }else{
    8. QMessageBox::about(this,"NOT Connected","NOT Connected");
    9. }
    To copy to clipboard, switch view to plain text mode 

    and I've got "NOT Connected"
    What I'm doing wrong?

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QODBC by QT

    If db not open look at QSqlDatabase::lastError.

  3. #3
    Join Date
    May 2019
    Posts
    9
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QODBC by QT

    I've got:
    Driver not loaded

  4. #4
    Join Date
    May 2019
    Posts
    9
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QODBC by QT

    I've found in Windows 7 "ODBC Configuration":3.png

    with "MyDRIVER". Test connection display "connection ok".

    Now I'm trying connect by using "MyDRIVER":
    Qt Code:
    1. db = QSqlDatabase::addDatabase("QODBC");
    2. QString connectString = "DRIVER={MyDRIVER}";
    3. db.setDatabaseName(connectString);
    4. if(db.open())
    5. {
    6. QMessageBox::about(this,"Connected","Connected");
    7. }else{
    8. QMessageBox::about(this,"NOT Connected","NOT Connected");
    9. QMessageBox::about(this,"NOT Connected",db.lastError().databaseText());
    10. }
    To copy to clipboard, switch view to plain text mode 

    And i've got:
    "NOT Connected"
    "Driver not loaded"


  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QODBC by QT

    "Driver not loaded" could mean that the QSql Plugin for QODBC is not present or fails to load.

    You should be able to get more information by setting the QT_DEBUG_PLUGINS variable, see https://doc.qt.io/qt-5/deployment-pl...ugging-plugins

    Cheers,
    _

Similar Threads

  1. QODBC on Mac
    By Eduardo Huerta in forum Newbie
    Replies: 0
    Last Post: 8th February 2019, 04:04
  2. Qodbc
    By Suths in forum Qt Programming
    Replies: 1
    Last Post: 19th March 2012, 01:44
  3. Error on QODBC
    By METEOR7 in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2012, 20:44
  4. SSL with QODBC ??!
    By codeman in forum Qt Programming
    Replies: 0
    Last Post: 21st September 2010, 10:01
  5. QODBC driver
    By martisho in forum Qt Programming
    Replies: 2
    Last Post: 7th April 2010, 20:48

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.