コード例 #1
0
        public static DataTable GetDataReport(string procedureName, string[] parameterField, string[] param)
        {
            DataTable  result;
            IDbContext ctx = DbFactory.Configure();

            try
            {
                ctx.CommandText = procedureName;
                ctx.CommandType = CommandType.StoredProcedure;
                ctx.Clear();
                //Add Parameter
                int count = parameterField.Length;
                for (int i = 0; i < count; i++)
                {
                    ctx.Add(parameterField[i], param[i]);
                }

                //Get DataReader
                result = DaoBase.GetDataTable(ctx);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
            finally
            {
                ctx.Close();
            }

            return(result);
        }
コード例 #2
0
        public static IDataReader GetDataReader(IDbContext ctx)
        {
            // Untuk keperluan error handling & loging
            try
            {
                //Error bila untuk app windows, jadi diabaikan saja
                HttpContext.Current.Session["_LastSqlException"] = null;
                HttpContext.Current.Session["_LastSqlCommand"]   = ctx.Command;
            }
            catch (Exception) {}


            IDataReader idr;

            try
            {
                idr = ctx.Command.ExecuteReader();
            }
            catch (SqlException ex)
            {
                try
                {
                    //Error bila untuk app windows, jadi diabaikan saja
                    HttpContext.Current.Session["_LastSqlException"] = ex;
                }
                catch (Exception) { }
                throw new Exception(ex.Message, ex);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
            finally
            {
                ctx.Clear();
            }
            return(idr);
        }
コード例 #3
0
ファイル: DaoBase.cs プロジェクト: tjhaihen/Basecamp
        public static IDataReader GetDataReader(IDbContext ctx)
        {
            // Untuk keperluan error handling & loging
            try
            {
                //Error bila untuk app windows, jadi diabaikan saja
                HttpContext.Current.Session["_LastSqlException"] = null;
                HttpContext.Current.Session["_LastSqlCommand"] = ctx.Command;
            }
            catch (Exception){}

            IDataReader idr;
            try
            {
                idr = ctx.Command.ExecuteReader();
            }
            catch (SqlException ex)
            {
                try
                {
                    //Error bila untuk app windows, jadi diabaikan saja
                    HttpContext.Current.Session["_LastSqlException"] = ex;
                }
                catch (Exception) { }
                throw new Exception(ex.Message, ex);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
            finally
            {
                ctx.Clear();
            }
            return idr;
        }
コード例 #4
0
 public Task Clear()
 {
     return(_context.Clear());
 }