Check if SQL Connection is Open or Closed

前端 未结 9 1762
春和景丽
春和景丽 2020-12-08 01:47

How do you check if it is open or closed I was using

 if (SQLOperator.SQLCONNECTION.State.Equals(\"Open\"))

however, even the State is \'Op

9条回答
  •  情书的邮戳
    2020-12-08 02:22

    Check if a MySQL connection is open

    ConnectionState state = connection.State;
    if (state == ConnectionState.Open)
    {
        return true;
    }
    else
    {
        connection.Open();
        return true;
    }
    

提交回复
热议问题