Results 1 to 4 of 4

Thread: problem in using QODBC ???????

  1. #1
    Join Date
    Oct 2011
    Posts
    5
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Angry problem in using QODBC ???????

    hi
    i want to use QODBC for use ms Access database.


    Qt Code:
    1. QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    2. db.setDatabaseName("Driver={Microsoft Access Driver (*.mdb, *.accdb)};DSN='';DBQ=Data.mdb");
    3. if(!db.open())
    4. QMessageBox::information(this,"",db.lastError().text());
    To copy to clipboard, switch view to plain text mode 



    but have this error : QSqlError(0, "QODBC3: Unable to connect", " [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified").

    please help me for solve this problem.
    Thanks.

  2. #2
    Join Date
    Aug 2009
    Location
    Greece
    Posts
    69
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem in using QODBC ???????

    Is your Data.mdb in the same directory with your executable? Try setting a full path and see if it throws an error.

  3. The following user says thank you to Rhayader for this useful post:

    saeed (15th November 2011)

  4. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: problem in using QODBC ???????

    Quote Originally Posted by saeed View Post
    Qt Code:
    1. QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    2. db.setDatabaseName("Driver={Microsoft Access Driver (*.mdb, *.accdb)};DSN='';DBQ=Data.mdb"); // <<<<<< DSN=''
    3. if(!db.open())
    4. QMessageBox::information(this,"",db.lastError().text());
    To copy to clipboard, switch view to plain text mode 

    but have this error : QSqlError(0, "QODBC3: Unable to connect", " [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified").
    I have emphasised the two pieces of information that I would put together. Do you really have a predefined data source (in your ODBC admin) that is called ''?

    Here is an ODBC connection string that I use on a legacy database:
    Qt Code:
    1. // construct an ODBC connection string for the Access Db
    2. QString conn = QString("Driver={Microsoft Access Driver (*.mdb)};Dbq=%1;Uid=Admin;Pwd=;").arg(fileName);
    To copy to clipboard, switch view to plain text mode 
    but you could start by just removing the DSN=''.

  5. The following user says thank you to ChrisW67 for this useful post:

    saeed (15th November 2011)

  6. #4
    Join Date
    Oct 2011
    Posts
    5
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem in using QODBC ???????

    Qt Code:
    1. QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    2. db.setDatabaseName("Driver={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=Data.mdb");
    3. if(!db.open())
    4. qDebug() <<db.lastError();
    To copy to clipboard, switch view to plain text mode 




    I use this code and got my issue was resolved
    Thank you for your assistance

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 on BLOB
    By baray98 in forum Qt Programming
    Replies: 0
    Last Post: 6th November 2009, 23:26
  5. QODBC Driver
    By mchara in forum Qt Programming
    Replies: 2
    Last Post: 17th January 2008, 14:40

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.