给我这个错误connection must be valid and open
我不知道如何解决它。
private void loginUtenti(string user, string psw)
{
createConnection();
string connectionString = "server=localhost;user=root;database=test;port=3306;password=******;"; ;
MySqlConnection connection = new MySqlConnection(connectionString);
command = new MySqlCommand();
command.CommandText = "SELECT Psw FROM Utenti WHERE Nome = '" + user + "';";
object passwordInput = command.ExecuteScalar(); // error "connection must be valid and open"
string nullo = "";