MySql.Data.MySqlClient.MySqlCommand.CheckState C# (CSharp) Method

CheckState() private method

Check the connection to make sure - it is open - it is not currently being used by a reader - and we have the right version of MySQL for the requested command type
private CheckState ( ) : void
return void
		private void CheckState()
		{
            // There must be a valid and open connection.
            if (connection == null)
                throw new InvalidOperationException("Connection must be valid and open.");

            if (connection.State != ConnectionState.Open && !connection.SoftClosed)
                throw new InvalidOperationException("Connection must be valid and open.");

			// Data readers have to be closed first
			if (connection.Reader != null)
				throw new MySqlException("There is already an open DataReader associated with this Connection which must be closed first.");
		}