I am trying to access a MS Access database from a ASP MVC application using OleDb. The provider I am using in the connection string is Microsoft.ACE.OLEDB.12.0.
When I launch the application from Visual Studio everything works fine (Access is installed in my computer). I have published the WebApp on a Windows Server 2012 (IIS 8), installed the Access Database Engine 64 bits on the machine and everything works as expected too.
But now I need to install the application on a Windows Server 2008 (IIS 7.5). And I get the most odd behaviour on that machine depending on what I include on the WHERE clause of my query.
If I query against any field that is of Text type there is no problem. E.g., this is ok:
SELECT * FROM MYTABLE WHERE TEXTFIELD = "SOMETHING"
But if I query against, let´s say, a Number field:
SELECT * FROM MYTABLE WHERE NUMBERFIELD = 666
I always get a
System.Data.OleDb.OleDbException (0x80040E14): Internal OLE Automation error
I cannot even query
SELECT * FROM MYTABLE WHERE 666 = 666
The strange thing is that if I try to UPDATE (or INSERT) the table, I have no problem in updating any type of field (text, numbers, dates), AS LONG AS the WHERE clause of the UPDATE statement doesn´t include any field other than a Text type.
I have tried also
SELECT * FROM MYTABLE WHERE Str(NUMBERFIELD) = "666"
and then whole Application Pool crashes, starts automatically again and crashes! (The Event Log says "A process serving application pool 'MyAppPool' suffered a fatal communication error with the Windows Process Activation Service. The process id was '12220'. The data field contains the error number.", with an Event Id of 5011).
If I create an Access Query with something like "SELECT Str(2) AS StrField FROM SOMETABLE" and call it MYACCESSQUERY, and then I query from my app against that Access Query with just a simple "SELECT * FROM MYACCESSQUERY" THE AppPool crashes too!.
After a lot of searches in a number of places the Internal OLE Automation error is related with the use of parameters, but mine doesn´t seem to be the case: after all, is the leftmost part of the expression what is giving me trouble (the field part in NUMBERFIELD = 666), not the rightmost part (the value 666 I am testing, that is usually the part that is passed using a parameter).
I have tried to construct the queries with or without parameters to no avail, I have compared the different machine´s Application Pools and they look the same, the Access Database Engine I have installed is the same, too.
Everything I try works flawlessly in my developing machine and in my test server, but when I try to run it on the client´s server, nothing, I always get a "Internal OLE Automation error" unless I query only against Text type fields (or even worse, I crash the whole Application Pool).
Please help, I am running out of ideas that could explain this strange behaviour.
Just in case someone is in the same situation.
Although it is not stated anywhere as something necessary (or even related), installing the Microsoft Access 2016 Runtime found on https://www.microsoft.com/en-us/download/confirmation.aspx?id=50040 solved the problem (and boosted the access speed to the database too).
I am still scratching my head why.
User contributions licensed under CC BY-SA 3.0