Results 1 to 4 of 4

Thread: Qt how to open SQL Compact Server file .sdf

  1. #1
    Join Date
    Aug 2009
    Posts
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qt how to open SQL Compact Server file .sdf

    I am trying to open a SQL Compact Server file .sdf with Qt. I have the following code:
    Qt Code:
    1. QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    2. db.setDatabaseName("C:\\testresults.sdf");
    3. bool Success = db.open();
    4.  
    5. sprintf(writeToMonitorBuffer, "dblastError = %s", (const char *)db.lastError().text().toLatin1());
    6. writeToMonitor(writeToMonitorBuffer);
    7.  
    8. sprintf(writeToMonitorBuffer, "db.open(): Success/Fail = %s", Success ? "Pass" : "Fail");
    9. writeToMonitor(writeToMonitorBuffer);
    To copy to clipboard, switch view to plain text mode 

    I am getting the error message:
    Qt Code:
    1. dblastError = [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified QODBC3: Unable to connect
    To copy to clipboard, switch view to plain text mode 

    And I get:
    Qt Code:
    1. db.open(): Success/Fail = Fail
    To copy to clipboard, switch view to plain text mode 


    In the past I have connected to MS Access database by using
    Qt Code:
    1. db.setDatabaseName("Driver={Microsoft Access Driver (*.mdb, *.accdb)};DSN='';DBQ=C:\\temp\\TestEng_TestDatabase.accdb");
    To copy to clipboard, switch view to plain text mode 

    Not sure what I should be putting for
    "Driver={???}

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,552
    Thanks
    13
    Thanked 1,579 Times in 1,508 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt how to open SQL Compact Server file .sdf

    There is no out-of-the-box ODBC driver for Sql Server Compact Ed AFAICT. Your options are limited to .Net or OLEDB interfaces.

  3. #3
    Join Date
    Aug 2009
    Posts
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt how to open SQL Compact Server file .sdf

    So what does that mean? Qt cannot open a SQL compact server file?
    How would I implement the .Net or OLEDB interface in Qt?

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

    Default Re: Qt how to open SQL Compact Server file .sdf

    There is no ODBC support for Sql Server Compact Ed and therefore the standard Qt ODBC Sql database driver cannot access it.

    Your C++ program can access Sql Server Compact Ed databases using the Microsoft OLE DB API directly.
    You may also be able to access the data through ActiveQt.
    You could, of course, write a Qt SQL driver specifically for Sql Server Compact Ed.

Similar Threads

  1. Sending information to server over an open HTTP connection
    By Pieter from Belgium in forum Qt Programming
    Replies: 5
    Last Post: 28th August 2013, 15:37
  2. Replies: 4
    Last Post: 5th December 2011, 17:54
  3. Compact View
    By wirasto in forum Qt Programming
    Replies: 7
    Last Post: 17th July 2010, 14:39
  4. Replies: 4
    Last Post: 9th May 2010, 16:18

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.