public void ExecuteReader(string sqlCommand, ReaderDelegateHandler dbReader) { try { Open(); using (IDbCommand comm = _conn.CreateCommand()) { comm.Connection = _conn; comm.CommandType = CommandType.Text; comm.CommandText = sqlCommand; AddParameter(comm); using (IDataReader dr = comm.ExecuteReader()) { if (dbReader != null) { dbReader(dr); } } } } catch (DbException ex) { throw new Exception(ex.Message); } catch (Exception ex) { throw new Exception(ex.Message); } finally { ClearParameter(); CloseConnection(); } }
public void ExecuteReaderProc(string procName, ReaderDelegateHandler dbReader) { try { Open(); using (IDbCommand comm = _conn.CreateCommand()) { comm.Connection = _conn; comm.CommandType = CommandType.StoredProcedure; comm.CommandText = procName; AddParameter(comm); using (IDataReader dr = comm.ExecuteReader()) { if (dbReader != null) { dbReader(dr); } } } } catch (Exception ex) { throw; } finally { ClearParameter(); CloseConnection(); } }
public static void ExecuteReader(ReaderDelegateHandler DBReader, DbConnection conntion, bool longConnection, CommandType commandType, string cmdText, params DbParameter[] cmdParams) { DbCommand cmd = conntion.CreateCommand(); try { PrepareCommand(cmd, conntion, null, commandType, cmdText, cmdParams); if (conntion.State != ConnectionState.Open) { conntion.Open(); } using (DbDataReader dr = cmd.ExecuteReader()) { if (DBReader != null) { DBReader(dr); } if (!dr.IsClosed) { dr.Close(); } } } catch (Exception ex) { throw ex; } finally { if (!longConnection) { if (conntion.State != ConnectionState.Closed) { conntion.Close(); } conntion.Dispose(); } cmd.Parameters.Clear(); cmd.Dispose(); } }
void IptBaseDb.ExecuteReaderS(string storedProcedureName, ReaderDelegateHandler dbReader) { throw new NotImplementedException(); }
void IptBaseDb.ExecuteReader(string sqlCommand, ReaderDelegateHandler dbReader) { throw new NotImplementedException(); }
public void ExecuteReader(CommandType commandType, string sqlCommand, ReaderDelegateHandler dbReader, params DbParameter[] param) { SqlHelper.ExecuteReader(dbReader, dalInfo.Connection, dalInfo.LongConnection, commandType, sqlCommand, param); }
public void ExecuteReader(CommandType commandType, string sqlCommand, ReaderDelegateHandler dbReader) { SqlHelper.ExecuteReader(dbReader, dalInfo.Connection, dalInfo.LongConnection, commandType, sqlCommand, null); }
public static void ExecuteReader(ReaderDelegateHandler DBReader, DbConnection conntion, bool longConnection, string cmdText, params DbParameter[] cmdParams) { ExecuteReader(DBReader, conntion, longConnection, CommandType.Text, cmdText, cmdParams); }