codice:
        MySQL = "SELECT COUNT(*) FROM user1 WHERE username = '" + txtUsername.Text + "'"; 
        MyRs = "SELECT Password FROM user1 WHERE username = '" + txtUsername.Text + "'"; 

		 MyConn = new OdbcConnection("DRIVER={MySQL ODBC 5.1 Driver};SERVER=xxx.xxx.xxx.xxx;Port=3306;DATABASE=xxxxxxx;USER=xxxxxx;PASSWORD=xxxxxxx;");
        MyCount = new OdbcCommand(MySQL, MyConn); 
        MyPassword = new OdbcCommand(MyRs, MyConn); 
        
        MyConn.Open(); 

        IntUsernameCount = (int) MyCount.ExecuteScalar();
ottengo l'errore:

System.InvalidCastException: Specified cast is not valid.