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:
Code:
db.setDatabaseName("C:\\testresults.sdf");
bool Success = db.open();
sprintf(writeToMonitorBuffer, "dblastError = %s", (const char *)db.lastError().text().toLatin1());
writeToMonitor(writeToMonitorBuffer);
sprintf(writeToMonitorBuffer, "db.open(): Success/Fail = %s", Success ? "Pass" : "Fail");
writeToMonitor(writeToMonitorBuffer);
I am getting the error message:
Code:
dblastError = [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified QODBC3: Unable to connect
And I get:
Code:
db.open(): Success/Fail = Fail
In the past I have connected to MS Access database by using
Code:
db.setDatabaseName("Driver={Microsoft Access Driver (*.mdb, *.accdb)};DSN='';DBQ=C:\\temp\\TestEng_TestDatabase.accdb");
Not sure what I should be putting for
"Driver={???}
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.
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?
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.