Issue with MySQL Connector/NET
sql server - MySQL Connector net Why we need it? - Stack Overflow
asp.net - .net mySQL Connector for a 64 bit machine - Stack Overflow
MySQL Connector NET 8.1.0 - Oracle Forums
Hi,
In order to pull data from a MySQL database, I installed MySQL Connector/net.
But when accessing "Get data from other source" menu and selecting "MySQL database", I get this error :
"This connector requires one or more additional components to be installed before it can be used".
MySQL Connector/net is indeed installed from https://dev.mysql.com/downloads/connector/net/
The page https://learn.microsoft.com/en-us/power-query/connectors/mysql-database gives command to check whether the MySQL Connector/net package is correctly installed. The command is
[System.Data.Common.DbProviderFactories]::GetFactoryClasses()|ogv
But this command gives error :
"Exception when calling "GetFactoryClasses" with arguments "0": "An error occurred while creating the configuration section handler for system.data: The column 'InvariantName' is restricted to be unique. The value 'is already present Mysql.Data.MySqlClient'. (C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config line 157)"En línea: 1 Carácter: 1+ [System.Data.Common.DbProviderFactories]::GetFactoryClasses()|ogv+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException+ FullyQualifiedErrorId : ConfigurationErrorsException"
MySQL connector/NET is version 9.1.0. It's the same with version 9.2.0.
PowerBI is in version 2.130.930.0. Same error with the latest version 2.139.1678.0.
Is there any specific setting for this ?
Thanks
It appears that your problem is due to a corrupt install of MySQL connector for .Net as described on MySQL website. http://bugs.mysql.com/bug.php?id=23071
Their recommendation is to manually add the missing MySQL Data Provider entries in the Machine.config under DbProviderFactories section.
You could always try and un-install and re-install if you haven't tried that already.
OK, I'm going to answer this question and then close it as although I couldn't get the real fancy Microsoft way of adding a datasource I did it the old fashioned way. Not the super nice way but this was just me learning, so after you see this example please know that I'm a long way off still.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using MySql.Data.MySqlClient;
namespace MyFitnessApp
{
public partial class _Default : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
MySqlConnection mss = new MySqlConnection("server=IP Address;Port=####;Database=db_name;Uid=userId;Pwd=password;");
string strSQL = "";
strSQL = "SELECT * FROM TABLE;";
MySqlDataAdapter mda = new MySqlDataAdapter(strSQL,mss);
DataSet myDS = new DataSet();
mda.Fill(myDS,"TABLE");
this.GridView1.DataSource = myDS;
this.GridView1.DataBind();
}
}
}
}
I'd like to figure out how to call the connectionstring from the web.config but this is what I found in several examples.
What is ironic is that I'm much more comfortable in VB.Net and I'm learning C#. The example I found was written in VB.Net and I converted it to C#. (: