Exemplo n.º 1
0
 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();
     }
 }
Exemplo n.º 2
0
 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();
     }
 }
Exemplo n.º 3
0
        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();
            }
        }
Exemplo n.º 4
0
 void IptBaseDb.ExecuteReaderS(string storedProcedureName, ReaderDelegateHandler dbReader)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
 void IptBaseDb.ExecuteReader(string sqlCommand, ReaderDelegateHandler dbReader)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
 public void ExecuteReader(CommandType commandType, string sqlCommand, ReaderDelegateHandler dbReader, params DbParameter[] param)
 {
     SqlHelper.ExecuteReader(dbReader, dalInfo.Connection, dalInfo.LongConnection, commandType, sqlCommand, param);
 }
Exemplo n.º 7
0
 public void ExecuteReader(CommandType commandType, string sqlCommand, ReaderDelegateHandler dbReader)
 {
     SqlHelper.ExecuteReader(dbReader, dalInfo.Connection, dalInfo.LongConnection, commandType, sqlCommand, null);
 }
Exemplo n.º 8
0
 public static void ExecuteReader(ReaderDelegateHandler DBReader, DbConnection conntion, bool longConnection, string cmdText, params DbParameter[] cmdParams)
 {
     ExecuteReader(DBReader, conntion, longConnection, CommandType.Text, cmdText, cmdParams);
 }