System.Data.Common.DbDataAdapter.UpdateConnectionOpen C# (CSharp) Method

UpdateConnectionOpen() private method

private UpdateConnectionOpen ( IDbConnection connection, StatementType statementType, IDbConnection connections, ConnectionState connectionStates, bool useSelectConnectionState ) : ConnectionState
connection IDbConnection
statementType StatementType
connections IDbConnection
connectionStates ConnectionState
useSelectConnectionState bool
return ConnectionState
        private ConnectionState UpdateConnectionOpen(IDbConnection connection, StatementType statementType, IDbConnection[] connections, ConnectionState[] connectionStates, bool useSelectConnectionState)
        {
            Debug.Assert(null != connection, "unexpected null connection");
            Debug.Assert(null != connection, "unexpected null connection");
            int index = (int)statementType;
            if (connection != connections[index])
            {
                // if the user has changed the connection on the command object
                // and we had opened that connection, close that connection
                QuietClose(connections[index], connectionStates[index]);

                connections[index] = connection;
                connectionStates[index] = ConnectionState.Closed; // required, open may throw

                QuietOpen(connection, out connectionStates[index]);
                if (useSelectConnectionState && (connections[0] == connection))
                {
                    connectionStates[index] = connections[0].State;
                }
            }
            return connection.State;
        }