close

今天有客戶要使用外部Mysql,透過IIS連外面的檔案 

但由於沒有設定data provider所以連不上,

他提供的設定方式如下網址:

https://www.cnblogs.com/vipsoft/archive/2012/11/08/2761121.html

 

1、2两步为推荐做法

1. 将MySql.Data.dll放到 bin目录下面,或都安装 mysql-connector-net-6.0.0.msi

2.web.config 添加如下节点,注册版本号一致

  <system.data>
    <DbProviderFactories>
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.0.0.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
    </DbProviderFactories>
  </system.data>

 

 3.全局配置

在C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG中machine.config(xml文件)中有一个字段是<DbProviderFactories> 有写入MySQL Data Provider 项,

如果是 .NET 4.0需要手动改一下 machine.config文件。将 v2.0.50727 下面的那段复制过去就OK了。

添加注册,<name= "SqlClient Data Provider">或者<name="MySQL Data Provider"...>

二選一即可 

 
<system.data>

    <DbProviderFactories>

      <add name="Odbc Data Provider" invariant="System.Data.Odbc" description=".Net Framework Data Provider for Odbc" type="System.Data.Odbc.OdbcFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

      <add name="OleDb Data Provider" invariant="System.Data.OleDb" description=".Net Framework Data Provider for OleDb" type="System.Data.OleDb.OleDbFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

      <add name="OracleClient Data Provider" invariant="System.Data.OracleClient" description=".Net Framework Data Provider for Oracle" type="System.Data.OracleClient.OracleClientFactory, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

      <add name="SqlClient Data Provider" invariant="System.Data.SqlClient" description=".Net Framework Data Provider for SqlServer" type="System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

      <add name="SQL Server CE Data Provider" invariant="Microsoft.SqlServerCe.Client" description=".NET Framework Data Provider for Microsoft SQL Server 2005 Mobile Edition" type="Microsoft.SqlServerCe.Client.SqlCeClientFactory, Microsoft.SqlServerCe.Client, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />

     <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.0.0.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>

<add name="SqlClient Data Provider" invariant="System.Data.SqlClient" description=".Net Framework Data Provider for SqlServer" type="System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

    </DbProviderFactories>

</system.data>
arrow
arrow
    創作者介紹
    創作者 NetPC虛擬主機 的頭像
    NetPC虛擬主機

    NetPC虛擬主機的部落格

    NetPC虛擬主機 發表在 痞客邦 留言(0) 人氣()