I am using the following code to create an NEW MS Access file using the SQL API from Qt.
QString strDatabaseName;
if (strExt == ".DB")
{
oQtDatabase = QSqlDatabase::addDatabase(_TN("QSQLITE"), _TN("Redline_DB"));
strDatabaseName = strDatei;
}
if (strExt == ".MDB" || strExt == ".ACCDB")
{
oQtDatabase = QSqlDatabase::addDatabase(_TN("QODBC"), _TN("Redline_MDB"));
strDatabaseName = _TN("Driver={Microsoft Access Driver (*.mdb, *.accdb)};FIL={MS Access};DSN='';DBQ=") + QString::fromLatin1(strDatei);
}
oQtDatabase.setDatabaseName(strDatabaseName);
if (!oQtDatabase.open())
throw oQtDatabase.lastError();
The part for SQLite is succesful in creating a .DB File. Unfortunately QODBC throws an error:
[Microsoft][ODBC-Treiber für Microsoft Access] Datei '(unbekannt)' nicht gefunden. QODBC3: Unable to connect
Which means: ODBC-driver for Microsoft Access, File 'unkown' not found
I have to mention that the connection string works well with an existing Access file.
Thanks in advance for your help.