Results 1 to 2 of 2

Thread: Qodbc

  1. #1
    Join Date
    Jan 2012
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Qodbc

    Hi everyone,

    Just wondering if anyone had any guidance for how to get QODBC to work inside visual studio 2008? so far i have downloaded Qt libraries 4.8.0 for Windows (VS 2008, 273 MB), and followed the online instructions for compiling the plugin, navigating to C:\Qt\4.8.0\src\plugins\sqldrivers\odbc, then running qmake odbc.pro, then nmake, however when i try to open a connection to the server I get
    'Error "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified QODBC3: Unable to connect" '

    Does any one have any ideas my code is as follows:
    Qt Code:
    1. QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    2. db.setHostName("LOCALHOST\\SQLEXPRESS");
    3. db.setDatabaseName("test");
    4. db.setUserName("...");
    5. db.setPassword("...");
    6.  
    7. if(db.open())
    8. {
    9. qDebug() << "Opened";
    10. db.close();
    11. }
    12.  
    13. else
    14. qDebug() << "Error" << db.lastError().text();
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Aug 2009
    Location
    Belgium
    Posts
    310
    Thanks
    10
    Thanked 31 Times in 25 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qodbc

    Hi,

    I use something like this for opening an Access database. The 'setDatabaseName is more complex then your "test". Maybe there's something similar for an Sql Express database.

    Qt Code:
    1. QSqlDatabase dbDci = QSqlDatabase::addDatabase("QODBC");
    2. dbDci->setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MSAccess};DBQ=dci.mdb");
    3. dbDci->open();
    To copy to clipboard, switch view to plain text mode 

    Regards,
    Marc

Similar Threads

  1. QODBC driver
    By hamidarr in forum Qt Programming
    Replies: 3
    Last Post: 21st July 2011, 00:09
  2. what different between QODBC and QODBC3
    By innobleday in forum Newbie
    Replies: 1
    Last Post: 26th April 2011, 13:22
  3. SSL with QODBC ??!
    By codeman in forum Qt Programming
    Replies: 0
    Last Post: 21st September 2010, 09:01
  4. QODBC driver
    By martisho in forum Qt Programming
    Replies: 2
    Last Post: 7th April 2010, 19:48
  5. QODBC on BLOB
    By baray98 in forum Qt Programming
    Replies: 0
    Last Post: 6th November 2009, 23:26

Tags for this Thread

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.