我使用的是visual studio 2012 c#去链接带有可视化界面mysql workbench 的mysql

运行是正常的,但是总是连接失败,错误信息是

求大神解答 应该怎么写连接的语句?
最新回答
念河山远

2024-09-13 03:19:10

方法1;
public DBMySQL(string database,string source,string id,string pwd,bool pooling,string charset,string port)
{
mylogin = @"Database=" + database + ";Data Source=" + source + ";User Id=" + id + ";Password=" + pwd + ";pooling=" + pooling +";CharSet=" + charset + ";port=" + port + "";
}
方法2:
public DBMySQL(string database, string source, string id, string pwd,bool pooling, string charset)
{
mylogin = @"Database=" + database + ";Data Source=" + source + ";User Id=" + id + ";Password=" + pwd + ";pooling=" + pooling +";CharSet=" + charset + ";port=3306";
}
方法3:
public DBMySQL(string database, string source, string id, string pwd, bool pooling)
{
mylogin = @"Database=" + database + ";Data Source=" + source + ";User Id=" + id + ";Password=" + pwd + ";pooling=" + pooling + ";CharSet=utf8;port=3306";
}
方法4:
public DBMySQL(string database, string source, string id, string pwd)
{
mylogin = @"Database=" + database + ";Data Source=" + source + ";User Id=" + id + ";Password=" + pwd + ";pooling=false;CharSet=utf8;port=3306";
}

完整的连接
//public string mylogin = @"Database=xtserver;Data Source=localhost;User Id=root;Password=me24851;pooling=false;CharSet=utf8;port=3306";