0

since cumulative Windows 10 1909 Updates are installed, I get following exception when accessing MS Access accdb. : An external component raised an exception. After reinstalling Microsoft ACE DatabaseEngine 2010 (OLEDB.12.0 ..), all works fine again. What can I do about it?

Dim sel As String = "Select Notiz from T_TerminNotiz where ztrText=@ztrText and serNr=@serNr"
Using myConnection As New OleDbConnection(myConnStringX1)
    myConnection.Open()

    Using mySqlCmd As New OleDbCommand(sel, myConnection)
        mySqlCmd.CommandType = CommandType.Text
        mySqlCmd.CommandTimeout = myCmdTimeOut
        mySqlCmd.CommandText = sel
        mySqlCmd.Parameters.Clear()
        mySqlCmd.Parameters.Add(New OleDbParameter("@ztrText", OleDbType.VarChar)).Value = strKlient
        mySqlCmd.Parameters.Add(New OleDbParameter("@serNr", OleDbType.Integer)).Value = serNr
        oRet = mySqlCmd.ExecuteScalar()
    End Using

End Using
ASh
  • 34,632
  • 9
  • 60
  • 82
woch
  • 1
  • You can get rid of the inner `Using` by putting a comma after the the first line of the first `Using` line and on the very next line put `mySqlCmd As New OleDbCommand(sel, myConnection)`. No need to `.Clear` the parameters collection; you just created the command; it can't have anything in the collection. Move `myConnection.Open()` to directly before the `.Execute...` – Mary May 27 '20 at 17:19

2 Answers2

0

Microsoft announces (Known issues with Office and Windows 10) that included Office 2010, but did not specify any technical details for developers. However, you did the best thing, considering that you will (anyway) provide DatabaseEngine 2010 Redist for the client.

Sometimes, the problem 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.

As stated in this answer [by/ Katia]. Hope this helps. Best of luck.

evry1falls
  • 194
  • 4
  • 15
  • But I have to reinstall MS DatabaseEngine 2010 Redist each time, when a new cumulative windows update is installed on the machine. – woch May 28 '20 at 07:53
  • Why do you say so? Is that actually happening with you? I mean, this is just a one time situation. – evry1falls May 28 '20 at 10:40
  • No, windows cumulative update overrites the corresponding dll's each time. – woch May 28 '20 at 13:13
  • Well, in the case I say you need to use another more reliable Database (i:e SqlServer). – evry1falls May 28 '20 at 13:29
0

after some tests, I found following solution to my problem.

  1. Installing Microsoft DatabaseEngine 2016.
  2. I activated all OLE DB Services by adding it into configuration file xxx.config. ... connectionString="Provider=Microsoft.ACE.OLEDB.16.0;Data Source=Table.accdb;Persist Security Info=True;OLE DB Services=-1;
woch
  • 1