If your application is using ASP.net+mysql database, you might get the following error when publishing to the server:
"Unable to find the requested .Net Framework Data Provider. It may not be installed."
Our server's default installed with MySQL Connector 6.6.4.0. If you use other Connector, What you need to do is upload related version of Dll MySql.Data.dll to your site bin folder.
TheMySQL.Data.dll locates on the "Installation path\Assemblies". Defaultpath is "C:\Program Files\MySQL\MySQL Connector Net 6.0.3\Assemblies".
Below is an example, sample.aspx:
<%@ Page Language="VB" debug="true" %>
<%@ Import Namespace = "System.Data" %>
<%@ Import Namespace = "MySql.Data.MySqlClient" %>
<script language="VB" runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Dim myConnection As MySqlConnection
Dim myDataAdapter As MySqlDataAdapter
Dim myDataSet As DataSet
Dim strSQL As String
Dim iRecordCount As Integer
myConnection = New MySqlConnection("Server=mysqlxxx.mysite4now.com;Database=DBname;Uid=DB_ID;Pwd=DB_pw")
strSQL = "SELECT * From [table name];"
myDataAdapter = New MySqlDataAdapter(strSQL, myConnection)
myDataSet = New Dataset()
myDataAdapter.Fill(myDataSet, "[table name]")
MySQLDataGrid.DataSource = myDataSet
MySQLDataGrid.DataBind()
End Sub
</script>
<html>
<head>
<title>MySQL test</title>
</head>
<body>
<form id="Form1" runat="server">
<asp:DataGrid id="MySQLDataGrid" runat="server" />
</form>
</body>
</html>
In some application you are required to add the following lines in web.config.
<system.web>
<compilation debug="true" urlLinePragmas="true">
<assemblies>
<add assembly="MySql.Data,Version=6.9.9.0, Culture=neutral,PublicKeyToken=C5687FC88969C44D"/></assemblies></compilation>
<authentication mode="Windows"/>
<customErrors mode="Off"/>
</system.web>
<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.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
</DbProviderFactories>
</system.data>
Article ID: 166, Created: July 25, 2012 at 12:37 AM, Modified: May 29, 2021 at 1:52 AM