public DataSet ExecuteAndReturnDataSet(SqlCommand com, string exceptionMessage) { using (_conn) { var result = new DataSet(); try { OpenConnection(); com.Connection = _conn; new SqlDataAdapter(com).Fill(result); } catch (Exception ex) { var ae = new DBCommandException(exceptionMessage, ex); ae.AttachDbCommandMetaData(com); throw ae; } finally { com.Dispose(); CloseConnection(); } return result; } }
public object ExecuteAndReturnScalar(SqlCommand com, string exceptionMessage) { using (_conn) { object result; try { OpenConnection(); com.Connection = _conn; result = com.ExecuteScalar(); } catch (Exception ex) { var ae = new DBCommandException(exceptionMessage, ex); ae.AttachDbCommandMetaData(com); throw ae; } finally { com.Dispose(); CloseConnection(); } return(result); } }
public TransactionStatus ExecuteTransaction(SqlCommand com, string exceptionMessage) { using (_conn) { var dt = new DataTable(); try { OpenConnection(); com.Connection = _conn; new SqlDataAdapter(com).Fill(dt); } catch (Exception ex) { var ae = new DBCommandException(exceptionMessage, ex); ae.AttachDbCommandMetaData(com); throw ae; } finally { com.Dispose(); CloseConnection(); } return(new TransactionStatus(dt)); } }
public DataSet ExecuteAndReturnDataSet(SqlCommand com, string exceptionMessage) { using (_conn) { var result = new DataSet(); try { OpenConnection(); com.Connection = _conn; new SqlDataAdapter(com).Fill(result); } catch (Exception ex) { var ae = new DBCommandException(exceptionMessage, ex); ae.AttachDbCommandMetaData(com); throw ae; } finally { com.Dispose(); CloseConnection(); } return(result); } }
public void Execute(SqlCommand com, string exceptionMessage) { using (_conn) { try { OpenConnection(); com.Connection = _conn; com.ExecuteNonQuery(); } catch (Exception ex) { var ae = new DBCommandException(exceptionMessage, ex); ae.AttachDbCommandMetaData(com); throw ae; } finally { com.Dispose(); CloseConnection(); } } }
public TransactionStatus ExecuteTransaction(SqlCommand com, string exceptionMessage) { using (_conn) { var dt = new DataTable(); try { OpenConnection(); com.Connection = _conn; new SqlDataAdapter(com).Fill(dt); } catch (Exception ex) { var ae = new DBCommandException(exceptionMessage, ex); ae.AttachDbCommandMetaData(com); throw ae; } finally { com.Dispose(); CloseConnection(); } return new TransactionStatus(dt); } }
public object ExecuteAndReturnScalar(SqlCommand com, string exceptionMessage) { using (_conn) { object result; try { OpenConnection(); com.Connection = _conn; result = com.ExecuteScalar(); } catch (Exception ex) { var ae = new DBCommandException(exceptionMessage, ex); ae.AttachDbCommandMetaData(com); throw ae; } finally { com.Dispose(); CloseConnection(); } return result; } }