使用create dataadapters创建MySQL Connector错误 [英] MySQL Connector error with create dataadapters
问题描述
I get one issues when I try to create dataadaper with MySQL providers , It's returns null.
Here is follow code with error:
string sDataBase = "MyDatabaseName";
string sUser =" MyUserName";
string sPasswd =" MyPassWord"
string _sProviderName =" MySql.Data.MySqlClient" ;;
_sConnection =" Persist Security Info = False; Server =" + sServer +" ;; Database =" + sDataBase +" ;; Uid =" + sUser +" ;; Pwd =" + sPasswd +" ;; SslMode = none" ;;
DbProviderFactory factory = DbProviderFactories.GetFactory("");
DbDataAdapter da = factory.CreateDataAdapter(); //这里为适配器返回null,当我尝试使用dataadapter时,我在下一行收到错误
RetAdp.SelectCommand = Cmd; //这里是错误发生的地方
我谷歌并看到其他人在mysql错误网站上有相同的错误,他们说这是.net框架的一个错误。
string _sProviderName = "MySql.Data.MySqlClient";
_sConnection = "Persist Security Info=False;Server=" + sServer + ";Database=" + sDataBase + ";Uid=" + sUser +";Pwd=" + sPasswd + ";SslMode=none";
DbProviderFactory factory = DbProviderFactories.GetFactory(""); DbDataAdapter da = factory.CreateDataAdapter(); //Here returns null for adapter and i get error in the next line when i try use dataadapter RetAdp.SelectCommand = Cmd; // here is where the error happen I google and saw others with the same error in the mysql bug site, and they talked this is a bug for .net framework .
有人解决了这个bug吗?
Anyone solved this bug ?
感谢您的关注。
推荐答案
将提供者不变名称指定为GetFactory参数:
Specify the provider invariant name as the GetFactory argument:
DbProviderFactory factory = DbProviderFactories.GetFactory(_sProviderName);
这篇关于使用create dataadapters创建MySQL Connector错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!