ODBC export to Excel does not work under Windows 7, Windows 8.x, and Windows 10

I just created the code (below) from scratch that shows a simple Excel export. The code fails with an exception when calling database.OpenEx .

Exception shown:

 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 

An English translation will look like "Reserved Error" and "Invalid Connection String Attribute"!

We can reproduce this on Windows 7, Windows 8.1 and Windows 10. We recommend that there is a problem with the Windows security update, but we are not sure. A similar code worked for years.

Can someone see the failures in the connection string?

Can anyone reproduce this problem?

EDIT: Windows 7 cords will also be affected.

The following security issues cause the following issues:

 Windows 7 KB4041681 Windows 8.1 KB40416393 Windows 10 KB4040724 KB4041676 

Here's the code (code is just a quick 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 (ie 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; 
+3
source share
2 answers

The problem occurs due to a bug in security updates. Currently, I see no other solution than to delete, a security patch, or another export format.

Affected Fixes:

Windows 7 SP1 and Windows Server 2008 R2 SP

KB4041681 - 2017-10 Security Monthly accumulative capital for Windows 7 for x86 systems KB4041678 - 2017-10 Security Only quality update for Windows Embedded Standard 7 for x64-based systems

Windows 8.1 and Windows Server 2012 R2

KB4041693 - 2017-10 Security Monthly quality increase for Windows 8.1 for x86-based systems KB4041687 - 2017-10 Security Only quality update for Windows 8.1 for x86-based systems

Windows 10 and Windows Server 2016 (version 1607)

KB4041691 - 2017-10 Cumulative Update for Windows 10 Version 1607 and Windows Server 2016

Windows 10 and Windows Server 2016 (version 1703)

KB4041676 - 2017-10 Cumulative Update for Windows 10 Version 1703

There are several threads in other communities (Tectnet, Answers, Social MSDN) that discuss the same problem without any workaround other than removing the patch.

Edit (2017-11-21): for Windows 10 error fixed with KB4048955!

+3
source

I have exactly the same problem since updating Windows from 12/10/2017

The information below solves the problem on Win7, but the problem is not resolved on Win10. on Win10 it is ::SQLConfigDataSource(hwndParent, fRequest, sDriver, sAttributes) that ::SQLConfigDataSource(hwndParent, fRequest, sDriver, sAttributes) an "Unhandled exception"

SOLUTION for Win7:

I have additional parameters: FIL=Excel 2000,DriverID=790 DRIVER={Microsoft Excel Driver (*.xls)}

It seems to be solved using: FIL=Excel 12.0,DriverID=1046 DRIVER={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)}

This will work if you have an Excel version compatible with these options. You can also try the options between Excel 2000 and Excel 12.0.

For a PC with only Excel 2000, therefore, the new parameters do not work at first: to solve the problem, I install AccessDatabaseEngine_X64.exe from Microsoft Download; this allowed the use of the Microsoft Excel driver (* .xls, * .xlsx, * .xlsm, * .xlsb)

Example parameters:

 m_sDsn ="DRIVER={Microsoft Excel Driver (*.xls)};DSN='ODBC_NameXls';FIRSTROWHASNAMES=1;READONLY=TRUE;CREATE_DB="Excelfilename.xls";DBQ=Excelfilename.xls;FIL=Excel 2000;DriverID=790"; m_sDsn ="DRIVER={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DSN='ODBC_NameXls';FIRSTROWHASNAMES=1;READONLY=TRUE;CREATE_DB="Excelfilename.xls";DBQ=Excelfilename.xls;FIL=Excel 12.0,DriverID=1046"; m_Database->OpenEx(m_sDsn, CDatabase::openReadOnly | CDatabase::noOdbcDialog); 
+1
source

Source: https://habr.com/ru/post/1272556/


All Articles