我正在尝试使用Qt打开SQL Compact服务器文件.sdf。 我有以下代码:
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
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);
我收到错误消息:
dblastError = [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified QODBC3: Unable to connect
我得到了:
db.open(): Success/Fail = Fail
我该如何解决这个问题?