c#和mysql连接问题

2025-02-25 07:24:46
推荐回答(2个)
回答1:

public class DB
{

MySQLConnection con = null; //new MySQLConnection();
MySQLCommand cmd =new MySQLCommand();

public DB()
{

con = new MySQLConnection(new MySQLConnectionString("localhost", "business", "root", "").AsString);

con.Open();

}

其他不变

回答2:

你在方法DB的上面创建了一个con 你在方法DB里面又创建了一个con 当然会出错了.楼上的是对的
分你就给他吧