OleDbConnection gets “External component has thrown an exception.”

后端 未结 6 1793
予麋鹿
予麋鹿 2020-12-20 11:44

I\' m using a Windows Forms application to export data to excel.

Application is built both x64 and x86.

So both version of Microsoft Access Databse Engine mu

相关标签:
6条回答
  • 2020-12-20 12:14

    I had similar problems and I reinstalled the Microsoft Access Database Engine, using the repair option. It worked for me.

    0 讨论(0)
  • 2020-12-20 12:18

    I can propose a horrible solution but when you are under pressure, it works. Open the Excel file and save it as an xls file instead of xlsx. Install the ACEOLEDB.12 32 bit version and pull your data in that way. This is not the answer, but it may suffice as a work-around.

    For most occasions, the "Flat File" import in SQL Server option will work just fine.

    0 讨论(0)
  • 2020-12-20 12:20

    In my case I had Office 2013 x64 installed. I then installed AccessDatabaseEngine2016_X64.exe after which I installed AccessDatabaseEngine2016.exe using the "/quiet" switch. I found that if I installed the x86 engine first I would get the error you're seeing, so order matters. I also changed my connection strings to Provider=Microsoft.ACE.OLEDB.16.0 (which appears to provide better OleDb error reporting).

    You can verify driver installation using ODBC Data Sources.

    0 讨论(0)
  • 2020-12-20 12:31

    I had the same error. It was fixed when I changed Provider=Microsoft.ACE.OLEDB.12.0; to Provider=Microsoft.ACE.OLEDB.16.0; I was running Office 2016.

    0 讨论(0)
  • 2020-12-20 12:37

    This will usually occur when the build configuration platform in Visual Studio is incorrect, this can occur in both build configuration platforms, x86 and x64.

    This is due to a mismatch between the build configuration platform of your project and the Microsoft Access Database Engine which is installed on your machine.

    In order to resolve this error:

    • Change the build configuration platform in Visual Studio
    • make sure it matches
    • the Microsoft Access Database Engine version on your machine
    • Recompile and run your project
    • The run time error should now be resolved
    0 讨论(0)
  • 2020-12-20 12:37

    I have both 64 and 32 bit versions, and I had the same problem. I just went to the properties of the project and in the tab Build, I uncheck the box that says Prefer 32-bit.

    0 讨论(0)
提交回复
热议问题