简体   繁体   English

MS Access Connection在本地工作,但在生产环境中不工作

[英]MS Access Connection works in local but not working in production

As a MVC developer I am creating an application for a school, I have a MS Access db and it is located inside my application, in the app_data folder. 作为MVC开发人员,我正在为学校创建一个应用程序,我有一个MS Access数据库,它位于我的应用程序内的app_data文件夹中。 I created the connection string in the web.config file like below 我在web.config文件中创建了连接字符串,如下所示

<add name="WMOERP1" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source='|DataDirectory|\Register.mdb'" providerName="System.Data.OleDb" />

It works perfectly in my local system but when I uploaded it in production I got the error 它在我的本地系统中完美运行,但是当我在生产环境中上传它时出现错误

The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine 未在本地计算机上注册“ Microsoft.ACE.OLEDB.12.0”提供程序

Please help me how can I solve this I also tried to change the connection string below you can see that but still having the issue 请帮助我如何解决此问题,我也尝试更改下面的连接字符串,您可以看到但仍然存在问题

<add name="WMOERP1" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source='|DataDirectory|\Register.mdb'" providerName="System.Data.OleDb" />

Please help me . 请帮我 。

An application that uses the Microsoft.JET.OLEDB.4.0 is an application that runs in 32bit mode. 使用Microsoft.JET.OLEDB.4.0的应用程序是在32位模式下运行的应用程序。 Thus you have set your project properties to target the x86 CPU platform or you have set the AnyCPU target platform with the Prefer 32bit flag. 因此,您已将项目属性设置为以x86 CPU平台为目标,或者已将AnyCPU目标平台设置为具有“首选32位”标志。

In any case, when you deploy your application on IIS server 64 bit you should inform IIS that you want to run a 32bit application. 无论如何,当您在64位IIS服务器上部署应用程序时,应通知IIS您要运行32位应用程序。

This is done going to the IIS configurator, choose Application Pools, create or highlight the application pool where you app will run and, on the right click menu, choose the Advanced Settings menu. 完成此操作后,转到IIS配置器,选择“应用程序池”,创建或突出显示应用程序将在其中运行的应用程序池,然后在右键菜单上选择“高级设置”菜单。 From there set the Enable 32 bit application flag to true. 从那里将“启用32位应用程序”标志设置为true。 Restart everything. 重新启动所有内容。

Here a description of the process with a step by step images 在此通过逐步图像说明过程

Of course you could keep your original Microsoft.Jet.OLEDB.4.0 connection string because this library is deployed with the NET Framework libraries and you don't need to do anything. 当然,您可以保留原始的Microsoft.Jet.OLEDB.4.0连接字符串,因为此库与NET Framework库一起部署,并且您无需执行任何操作。
Instead to change to ACE.12.0 you need to install the libraries and, being your application a 32bit one, you need to install the 32bit version of ACE. 而不是更改为ACE.12.0,您需要安装这些库,并且作为32位应用程序,您需要安装32位版本的ACE。 The error seems to indicate that you have installed the 64bit version and thus there is no ACE.12.0 for 32bit apps (And no, you can't install both ACEs on the same machine) 该错误似乎表明您已经安装了64位版本,因此没有用于32位应用程序的ACE.12.0(不,您不能在同一台计算机上安装两个ACE)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM