每次运行代码时,我都会遇到这个问题.这是我的密码


class DB
{
private  MySqlConnection connection = new MySqlConnection("server=localhost;port:3306;username=root;password=;database=users_db");
public void openConnection()
{
if (connection.State == System.Data.ConnectionState.Closed)
{
connection.Open();
}
}
public void closeConnection()
{
if (connection.State == System.Data.ConnectionState.Open)
{
connection.Close();
}
}
public MySqlConnection getConnection()
{
return getConnection();
}
}
}

它成功运行,但在登录过程之后。。有一个例外

  • System.ArgumentException:'不支持关键字。参数名称:端口:3306;用户名'

问题在于":"在";端口";参数,则必须通过"="如本例所示:

"Server=myServerAddress;Port=1234;Database=myDataBase;Uid=myUsername;Pwd=myPassword;"

,你在这个页面上有很多例子吗

现在我在中遇到了这个问题

public MySqlConnection getConnection()
{
return getConnection();
}

System.StackOverflowException:引发了"System.StackOverflowException"类型的异常

最新更新