SqlScripter.Core/src/Data/SqlCommon.cs
/// <summary>
/// Ensures that <see cref="SqlCommand"/> have an opened <see cref="SqlConnection"/>.
/// Check if SqlCommand have an open SqlConnection assigned, if not new <see cref="SqlConnection"/>
/// is opened, existing <see cref="SqlConnection"/> is opened otherwise.
/// </summary>
Ensures that  have an opened .
Check if SqlCommand have an open SqlConnection assigned, if not new
is opened, existing  is opened otherwise.
Ensures that have an opened . Check if SqlCommand have an open SqlConnection assigned if not new is opened existing is opened otherwise .
private void EnsureOpenConnection(SqlCommand sqlCmd) {
            if (sqlCmd.Connection == null) {
                if (sqlCmd.Transaction != null && sqlCmd.Transaction.Connection != null) {
                    sqlCmd.Connection = sqlCmd.Transaction.Connection;
                    if (sqlCmd.Connection.State != ConnectionState.Open) {
                        sqlCmd.Connection.Open();
                    }
                } else {
                    SqlConnection sqlConnection = GetSqlConnection();
                    sqlCmd.Connection = sqlConnection;
                    sqlConnection.Open();
                }
            } else if (sqlCmd.Connection.State != ConnectionState.Open) {
                sqlCmd.Connection.Open();
            }
        }
private void EnsureOpenConnection ( SqlCommand sqlCmd ) { if ( sqlCmd . Connection == null ) { if ( sqlCmd . Transaction != null && sqlCmd . Transaction . Connection != null ) { sqlCmd . Connection = sqlCmd . Transaction . Connection ; if ( sqlCmd . Connection . State != ConnectionState . Open ) { sqlCmd . Connection . Open ( ) ; } } else { SqlConnection sqlConnection = GetSqlConnection ( ) ; sqlCmd . Connection = sqlConnection ; sqlConnection . Open ( ) ; } } else if ( sqlCmd . Connection . State != ConnectionState . Open ) { sqlCmd . Connection . Open ( ) ; } }
Ensures that  have an opened .
Ensures that have an opened .
sqlCmd
SqlCommand