问题描述
我试着连接到我的Web服务器上的MySQL数据库,但我不断收到:
Im trying to connect to a mysql database on my web server, but I keep getting:
Unable to find the requested .Net Framework Data Provider. It may not be installed.
即时猜测的ADO.NET连接器present因为如果我改变我的配置为:
Im guessing that the ADO.NET connector is present because if I change my config to:
providerName="System.Data.SQLClient"
我得到:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
我的供应商配置为:
My provider config is:
<add name="MySQLMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.0.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
autogenerateschema="true" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/" />
</providers>
我的连接字符串是:
My Connection string is:
<add name="LocalMySqlServer"
connectionString="Data Source=localhost;user id=web210-aaron;password=tester;database=web210-aaron;"
providerName="System.Data.MySQLClient"/>
林pretty的肯定,这是正确的,尤其是当我从我的本机上运行(更换主机服务器的IP),它运行perfecly!可能有人请证实,这是一个正确的连接字符串。
Im pretty sure this is correct, especially as if I run it from my local machine (changing the host to the server IP) it runs perfecly! Could someone please confirm that this is a correct connection string.
推荐答案
我要去回答我的问题,因为这浪费了我的生活了3天试图手动进行配置。的
- 您已经创建了一个MVC3 /剃须刀(可能还有其他的C#)应用程序
- 您正在使用MySql.Data.MySqlClient尝试连接到数据库
- 您能够从像Visual Studio 2010的IDE从本地计算机连接到本地数据库或者数据库服务器上,但无法连接时,该网站被部署
- 当你部署你的网站,你得到这个错误:
无法找到所需的.NET Framework数据提供。它可能没有安装。
当试图引用MySql数据库
- You have created an MVC3/razor (possibly other c#) application
- You are using MySql.Data.MySqlClient to try to connect to your database
- You are able to connect from an IDE like VS2010 from your local machine to either a local database or database on your server but unable to connect when the site is deployed
- When you deploy your web site, you get this error:
Unable to find the requested .Net Framework Data Provider. It may not be installed.
When trying to reference the MySql database
的问题是,你的网站无法找到引用MySQL.Data。
有几个部分这需要在你的 web.config中进行更改
文件,如 dbproviderfactories
和创建命名空间。这些可以手动添加,但它更简单,让工具来为你做它。
There are several sections which need to be changed in your web.config
file, such as dbproviderfactories
and creating namespaces. These can be added manually, but it is far more simple to allow the tools to do it for you.
您将需要包括相关的DLL在您的bin文件夹或更好,但使用Visual Studio的 SP1 以创建相关的文件夹,右击引用该项目(的有一个选项那里创建一个包含所有的DLL的bin文件夹)。确保MySql.Data.MySqlClient包含此文件夹中,如果不是,你应该能够从您的bin文件夹并将其拖到已建立由VS的新的。
您可以再使用的NuGet包管理器控制台来安装BLToolKit 。这将下载任何丢失的dll文件,将它们插入到你的文件夹,并自动正确引用它们。通过这种方式,你可以在你的MVC应用程序部署到那里可能没有安装MySql.Data(或任何其他DLL为此事)的Web服务器。
You can then use nuGet package manager console to install BLToolKit. This will download any missing dlls, insert them into your folders and correctly reference them automatically. This way, you can deploy your MVC application to a web server where MySql.Data (or any other dll for that matter) may not be installed.
这篇关于使用MVC3 ADO.NET的MySQL提供商(找不到请求的.Net Framework数据提供程序,它可能没有安装。)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!