.Net and Mysql connection string
.Net and Mysql connection string
dynasoft
Posts: 429Questions: 68Answers: 3
Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem: Hi, can anyone point me to examples for the above as I can't find any. I keep getting error Unable to find the requested .Net Framework Data Provider. Many thanks.
Answers
This thread should help, it's asking the same thing.
Cheers,
Colin
Hi,
Thanks. However I still get error 'Unable to find the requested .Net Framework Data Provider. It may not be installed.'. Are there drivers I need to install ? Conncting elsewhere in my code via ODBC works fine.
Bit of a basic question, but I assume you've downloaded the Editor package? Was this working for you before, or is this a new installation?
Colin
Hi, yes its all there. My project is working fine with sqlserver but setting tings up for mysql won't work for editor. Works fine elsewhere in my code. The project was built so it supports sqlserver and mysql. Last bit is to make Editor work with mysql
This is my connection settings for .NET and MySQL:
Could you take a look please and see if that's comparable to yours. We use .NET under Linux, but it should be the same.
Colin
Thanks. My code is in a Model class as per below:
Error ocurrs in the using line. Works fine with sqlserver. Thanks.
Adding a reference to the drivers to use does not fix the issue:
using (Database db = new Database("mysql", "Driver={MySQL ODBC 5.3 ANSI Driver};Server=127.0.0.1;Port=3306;Database=mydb;Uid=root;Pwd=mypswd;"))
I reference both MySqlConnector (1.2.1) and MySql.Data.dll (8.0.11). Could there be a conflict here?
Please advise
When set for
mysql
theDatabase
class will useMySql.Data.MySqlClient
[reference.MySql.Data.dll
I would have thought would be enough, butDriver={MySQL ODBC 5.3 ANSI Driver};
might be causing it issues. What if you drop that part?Allan
Thanks. I initially did not have
Driver={MySQL ODBC 5.3 ANSI Driver};
but it did not work either.What was the error without it, and does your project has a reference to the
MySQL.Data
library?Allan
.Error was the same:
'Unable to find the requested .Net Framework Data Provider. It may not be installed
MySql.Data.dll is referenced and in the bin folder
Is different case a problem?
I think Allan used 'MySQL.Data' in his reply. I have MySql.Data throughout and I just add the reference via the IDE so I don't think thats the issue.
Are you using .NET 5 / .NET Core or .NET Framework?
If 5 or Core, you need to register the client - e.g. in
Program.cs
you might have (inMain
):Along with a
using MySql.Data.MySqlClient;
line.Allan
I use .Net fw 4.72 so I think from what I see DbProviderFactories does not expose RegisterFactory
Adding the line
using MySql.Data.MySqlClient;
does not do anythingWould you have anything else I can look out for? Thanks.
Also I don't use Entity Fw.
Passing "MySql.Data.MySqlClient" as 3rd paramter to Database method and in using produces same error msg.
Adding to 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" />
</DbProviderFactories>
</system.data>
Seems to work. Still testing..
Adding that entry into web.config works well. Thanks.