Can't connect OdbcConnection Microsoft Access Driver - After publish System.Data.Odbc.OdbcException (0x80131937)
After publishing the application I lose OdbcConnection/Command functionality.
The code below is where the application errors out when published. In development all of this works.
//Connect to access .mdbcd
var conn = new OdbcConnection(@"Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=D:\wwwroot\mo22\storesales.mdb");
conn.Open();
//Clear out table
OdbcCommand Com = conn.CreateCommand();
Com.CommandText = "DELETE FROM tblAcctData";
Com.ExecuteNonQuery();
returnList.ForEach(el =>
{
OdbcCommand thisCmd = conn.CreateCommand();
thisCmd.CommandText = "INSERT INTO [tblAcctData] ([Store], [ProcDate], [Name], [Amount]) VALUES('" + el.Store + "', #" + el.proc_date + "#, '" + el.Name + "', " + el.amount + ")";
thisCmd.ExecuteNonQuery();
});
//Close connection
conn.Close();
So far I have
-added Microsoft Access to the server.
-added 32-bit and 64-bit Drivers in System Data Sources.
-Edited the connection string with additional credentials.
-Tried ExtendedAnsiSQL=1; in the connection string.
When I do add the 64 bit driver (Microsoft Access Driver (.mdb,.accdb)) in system data sources I don't get an error in the log anymore and I get this error on the front end.
t {headers: e, status: 502, statusText: "Bad Gateway", url: "http://apps.o.com/mochub2/api/acctlegenddata/getdata?stores=01&date=9/2/2019", ok: false, …}
So I feel like I am kind of getting somewhere because there is no odbc error. Just a error saying my gateway is bad.
Does anyone know what the next steps would be?
Here is the Error without the 64 bit Microsoft Access Driver.
System.Data.Odbc.OdbcException (0x80131937) at System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle) at System.Data.Odbc.OdbcConnectionOpen..ctor(OdbcConnection outerConnection, OdbcConnectionString connectionOptions) at System.Data.Odbc.OdbcConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.Odbc.OdbcConnection.Open() at mocHub2.Controllers.AcctLegendDataController.GetData(String stores, DateTime date) in C:\Ang\Controllers\AcctLegendDataController.cs:line 330 at lambda_method(Closure , Object , Object[] ) at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters) at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync() at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter() at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync() at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync() at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context)