I just created some code (at the bottom) from scratch that shows a simple Excel export. The code fails with an exception when database.OpenEx
is called.
The exception shown is:
Reservierter Fehler (-5016); es gibt keine Meldung für diesen Fehler.
Ungültiges Attribut für die Verbindungszeichenfolge. CREATE_DB
Ungültiges Attribut für die Verbindungszeichenfolge. CREATE_DB
Ungültiges Attribut für die Verbindungszeichenfolge. CREATE_DB
Ungültiges Attribut für die Verbindungszeichenfolge. CREATE_DB
Allgemeine Warnung Registrierungsschlüssel 'Temporary (volatile) Jet DSN for process 0x844 Thread 0x1850 DBC 0xab824c Excel' kann nicht geöffnet werden.
Ungültiges Attribut für die Verbindu
The english translation would be something like "Reserved Error" and "Invalid connection string attribut"!
We can repro this on Windows 7, Windows 8.1 and Windows 10. We suggest that there is a problem with a Windows security update, but we are not sure. Similar code worked for years.
Can anybody see failures in the connection string?
Can anybody repro this problem?
EDIT: Windows 7 seams to be affected too.
The following security patches causes this problems:
Windows 7 KB4041681
Windows 8.1 KB40416393
Windows 10 KB4040724
KB4041676
Here the code (the code is just a fast copy from Codeproject). My only change was to make it unicode compatible.
CDatabase database;
CString sDriver = _T("MICROSOFT EXCEL DRIVER (*.XLS)"); // exactly the same name as in the ODBC-Manager
CString sExcelFile = _T("demo.xls"); // Filename and path for the file to be created
CString sSql;
TRY
{
// Build the creation string for access without DSN
sSql.Format(_T("DRIVER={%s};DSN='';READONLY=FALSE;CREATE_DB=\"%s\";DBQ=%s"),
sDriver.GetString(), sExcelFile.GetString(), sExcelFile.GetString());
// Create the database (i.e. Excel sheet)
if (database.OpenEx(sSql,CDatabase::noOdbcDialog))
{
// Create table structure
sSql = _T("CREATE TABLE demo (Name TEXT,Age NUMBER)");
database.ExecuteSQL(sSql);
// Insert data
sSql = _T("INSERT INTO demo (Name,Age) VALUES ('Bruno Brutalinsky',45)");
database.ExecuteSQL(sSql);
sSql = _T("INSERT INTO demo (Name,Age) VALUES ('Fritz Pappenheimer',30)");
database.ExecuteSQL(sSql);
sSql = _T("INSERT INTO demo (Name,Age) VALUES ('Hella Wahnsinn',28)");
database.ExecuteSQL(sSql);
}
// Close database
database.Close();
}
CATCH_ALL(e)
{
e->ReportError();
e->Delete();
}
END_CATCH_ALL;