.net 连接mysql数据库的问题
一个小问题。我的程序以前连mysql数据库,端口是3306,可以连接,可是端口改成4506后,就连接不上了。程序如下:
连接字符串:
"Server=172.16.0.11:4506;persist security info=true;database=zbz_db;charset=gb2312;user id=root;password= "
try
{
MySqlConnection dbconnection0=new MySqlConnection(connections);
dbconnection0.Open();
mydataset=new DataSet ();
MySqlCommand sqlcmd = new MySqlCommand(sqlstr,dbconnection0);
adapter=new MySqlDataAdapter(sqlstr,dbconnection0);//连接到 SQL SERVER 数据库
adapter.SelectCommand = sqlcmd;
if (bpage)
{
adapter.Fill (mydataset,ctindex*pagesize,pagesize, "AA ");
}
else
{
adapter.Fill (mydataset);
}
adapter.Dispose();
sqlcmd.Dispose();
return mydataset.Tables[0];
}
catch
{
return null;
}
------解决方案-------------------- "Server=172.16.0.11;persist security info=true;database=zbz_db;charset=gb2312;user id=root;password=;port=4506 " 试试.
注意防火墙问题.
------解决方案--------------------该成,号
"Server=172.16.0.11,4506;persist security info=true;database=zbz_db;charset=gb2312;user id=root;password= "