当前位置: 首页>>代码示例>>C#>>正文


C# DbHelper类代码示例

本文整理汇总了C#中DbHelper的典型用法代码示例。如果您正苦于以下问题:C# DbHelper类的具体用法?C# DbHelper怎么用?C# DbHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DbHelper类属于命名空间,在下文中一共展示了DbHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetReaderGroup

        public ReaderGroup GetReaderGroup(int groupID)
        {
            try
            {
                using (var dbhelper = new DbHelper())
                {
                    // Fetch Reader Group
                    dbhelper.Command.CommandType = System.Data.CommandType.Text;
                    dbhelper.Command.CommandText = "SELECT [ReaderGroupID],[ReaderGroupName],[ReaderGroupDescription],[ReaderGroupLocation],[ReaderGroupZone] ,[ReaderDBConnectionString],[ReaderWCFConnectionString] FROM [RF].[ReaderGroup] WHERE [ReaderGroupID] = " + groupID.ToString();
                    DataSet ds = dbhelper.ExcuteDatset(dbhelper.Command);
                    if (ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                        throw new Exception("Reader Group not found for ID " + groupID);

                    ReaderGroup rdrGrp = DbHelper.DataTableToList<ReaderGroup>(ds.Tables[0]).FirstOrDefault();

                    // Fetch Readers
                    dbhelper.Command.CommandType = System.Data.CommandType.Text;
                    dbhelper.Command.CommandText = "SELECT [ReaderID],[ReaderGroupID],[ReaderTypeID],[ReaderName],[ReaderDescription],[IPAddress],[PortNo],[MACAddress],[AntennaPower],[ReaderPower],[LocationRef],[LocationDescription],[IsDeleted]  FROM [RF].[Reader] WHERE  [IsDeleted] = 0 AND [ReaderGroupID] = " + groupID.ToString();
                    DataSet dsReaders = dbhelper.ExcuteDatset(dbhelper.Command);

                    List<ReaderInfo> readersInfo = DbHelper.DataTableToList<ReaderInfo>(dsReaders.Tables[0]).ToList();
                    rdrGrp.Readers = readersInfo;

                    return rdrGrp;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:Systrics,项目名称:SystricsProjects,代码行数:31,代码来源:ReaderGroupDA.cs

示例2: Create

        /// <summary>
        /// 获取数据库帮助对象。
        /// </summary>
        /// <param name="database">数据库类型</param>
        /// <param name="host">数据库主机</param>
        /// <param name="instance">数据库实例</param>
        /// <param name="account">账号</param>
        /// <param name="password">密码</param>
        /// <param name="port">端口号</param>
        /// <returns>数据库帮助对象</returns>
        public static DbHelper Create(
            DatabaseType database,
            string host,
            string instance,
            string account,
            string password,
            int? port = null)
        {
            var connectionString = GetConnectionString(database, host, instance, account, password, port);
            var dbHelper = new DbHelper(Providers[(int)database], connectionString);

            switch (database)
            {
                case DatabaseType.MSSQL:
                    dbHelper.DbMetadata = new MSSQLMetadata();

                    break;
                case DatabaseType.Oracle:
                    dbHelper.DbMetadata = new OracleMetadata();

                    break;
            }

            return dbHelper;
        }
开发者ID:fenglinz,项目名称:Sparrow,代码行数:35,代码来源:DbHelperCreator.cs

示例3: Delete

        public bool Delete(Where where) {
 
            using (SqlCommand command = new DbHelper().Command) {
                string sql = $"delete from {Table} where {where.Result};";
                return command.ExecuteNonQueryExt(sql, where) > 0;
            }
        }
开发者ID:kangwl,项目名称:DotNet.Mix,代码行数:7,代码来源:UserDal.cs

示例4: GetspPharmacyStockCardList

 public static List<spPharmacyStockCard> GetspPharmacyStockCardList(String[] parameterField, String[] param)
 {
     List<spPharmacyStockCard> result = new List<spPharmacyStockCard>();
     IDbContext ctx = DbFactory.Configure();
     try
     {
         DbHelper helper = new DbHelper(typeof(spPharmacyStockCard));
         ctx.CommandText = "spfmrpt_KartuPersediaanFarmasi";
         ctx.CommandType = System.Data.CommandType.StoredProcedure;
         //Add Parameter
         int count = parameterField.Length;
         for (int i = 0; i < count; i++)
         {
             ctx.Add(parameterField[i], param[i]);
         }
         using (IDataReader reader = DaoBase.GetDataReader(ctx))
             while (reader.Read())
                 result.Add((spPharmacyStockCard)helper.IDataReaderToObject(reader, new spPharmacyStockCard()));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message, ex);
     }
     finally
     {
         ctx.Close();
     }
     return result;
 }
开发者ID:tjhaihen,项目名称:Basecamp,代码行数:29,代码来源:BusinessLayer.Proc.cs

示例5: ObterItemAESPorNumeroAES

        public List<DadosAES> ObterItemAESPorNumeroAES(string numeroAES)
        {
            List<DadosAES> listaAES = new List<DadosAES>();

            DbHelper db = new DbHelper();

            string cmdText = @"select b.Numero_AES, b.Item_AES
                                 from Frequencia4Edicao a, [dbo].[vw_mantida_curso_turma]  b
                                where 1=1
                                  and a.idCursoTurnoTurma = b.idCursoTurnoTurma
                                  and b.Numero_AES = @Numero_AES
                             group by b.Numero_AES, b.Item_AES
                             order by 2";

            db.AddParameter(new System.Data.SqlClient.SqlParameter("@Numero_AES", numeroAES));

            SqlDataReader dr = db.GetDataReader(cmdText);

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    listaAES.Add(new DadosAES
                    {
                        NumeroAES = dr["Numero_AES"].ToString(),
                        ItemAES = Convert.ToInt32(dr["Item_AES"])
                    });

                }
            }

            db.CloseDbConnection();

            return listaAES;
        }
开发者ID:felipeviola,项目名称:vence4edicao,代码行数:35,代码来源:RelatAcompMensalController.cs

示例6: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["uname"] == null)
        {
            Response.Write("<script>alert('系统超时或非法登录,请重新登录!');window.location.href='default.aspx';</script>");
            return;
        }
        if (Session["uid"]==null)
        {
            Response.Write("<script>alert('系统超时或非法登录,请重新登录!');window.location.href='default.aspx';</script>");
            return;
        }

        if (Session["ucount"] == null)
        {
            Response.Write("<script>alert('系统超时或非法登录,请重新登录!');window.location.href='default.aspx';</script>");
            return;
        }
        string uid = Session["uid"].ToString();
        dbh = new DbHelper();
        string sql;
        sql = string.Format("select count(*) from userinfo where parent_id='{0}' ", uid);
        DbCommand dbc = dbh.GetSqlStringCommond(sql);

        int count=int.Parse(dbh.ExecuteScalar(dbc).ToString());

        int usercount = int.Parse(Session["ucount"].ToString()); ;
        if (count >= usercount)
        {
            Response.Write("<script>alert('用户最大数超出设定范围,请联系管理员!');window.location.href='userlist.aspx';</script>");
            return;
        }

        if (Request["id"] != null)
        {

            id = Request["id"];

            sql = string.Format("select * from userinfo where id='{0}' ", Request["id"]);
            DbCommand dbc3 = dbh.GetSqlStringCommond(sql);
            dbr = dbh.ExecuteReader(dbc3);
            dbr.Read();
            tb_guid.Text = dbr["guid"].ToString();
            tb_memo.Text = dbr["memo"].ToString();
            tb_buydate.Text = dbr["buy_date"].ToString();
            tb_stopdate.Text = dbr["stop_date"].ToString();
            tb_username.Text = dbr["user_name"].ToString();
            rb_stop.Checked = dbr["active"].ToString() == "0" ? true : false;
            rb_active.Checked = dbr["active"].ToString() == "0" ? false : true;

        }
        else
        {
            tb_guid.ReadOnly = false;
            tb_buydate.Text = DateTime.Now.ToString("yyyyMMdd");
            tb_stopdate.Text = DateTime.Now.AddYears(1).ToString("yyyyMMdd");
            rb_stop.Checked = true;
        }
    }
开发者ID:wangshu,项目名称:printv2,代码行数:59,代码来源:UserInfo.aspx.cs

示例7: findEmployeeById

 public static Employee findEmployeeById(Guid id, DbHelper helper)
 {
     var query = from e in helper.Employees
                 where e.ID == id
                 select e;
     var em = query.FirstOrDefault();
     return em;
 }
开发者ID:XNMTA,项目名称:AutoOffice,代码行数:8,代码来源:CommonUser.cs

示例8: findEmployeeByMail

 public static Employee findEmployeeByMail(String mail, DbHelper helper)
 {
     var query = from e in helper.Employees
                 where e.MailAddress == mail
                 select e;
     var em = query.FirstOrDefault();
     return em;
 }
开发者ID:XNMTA,项目名称:AutoOffice,代码行数:8,代码来源:CommonUser.cs

示例9: findEmployeeByName

 public static Employee findEmployeeByName(String name, DbHelper helper)
 {
     var query = from e in helper.Employees
                 where e.Name == name
                 select e;
     var em = query.FirstOrDefault();
     return em;
 }
开发者ID:XNMTA,项目名称:AutoOffice,代码行数:8,代码来源:CommonUser.cs

示例10: getTagSQL

        protected override void getTagSQL()
        {
            tempCreate = "";
            rightsJoin = "";
            this.oper = queryParams.GetValue<int>(SParam.OPERATOR);

            DbHelper db = new DbHelper(conStr, true);
            addSQLInner();
        }
开发者ID:sarahCla,项目名称:SQLMaker,代码行数:9,代码来源:RightsSQLMaker.cs

示例11: frmGenres

        public frmGenres(DbHelper db, DataRow dr, FormMode mode)
            : base(db, dr, mode)
        {
            InitializeComponent();

            this.Load += frmGenres_Load;
            this.FormClosing += frmGenres_FormClosing;
            this.Shown += frmGenres_Shown;
        }
开发者ID:Dr1N,项目名称:CinemaTickets,代码行数:9,代码来源:frmGenres.cs

示例12: CreateProcedure

 /// summary
 /// �������ݿ�洢����
 /// /summary
 /// param name="procedureName"�洢������/param
 /// param name="procedureText"�洢��������/param
 public override void CreateProcedure(string procedureName, string procedureText)
 {
     if(procedureText != null && procedureText.Trim() != "")
     {
         DropProcedure(procedureName);
         DbHelper helper = new DbHelper();
         helper.ExecuteNonQuery(procedureText);
     }
 }
开发者ID:jokingzhou,项目名称:AnJi-DevZoneGIS,代码行数:14,代码来源:DbUtil.cs

示例13: frmCinema

        public frmCinema(DbHelper db)
            : base(db)
        {
            InitializeComponent();

            this.Load += frmCinema_Load;
            this.FormClosing += frmCinema_FormClosing;
            this.Shown += frmCinema_Shown;
        }
开发者ID:Dr1N,项目名称:CinemaTickets,代码行数:9,代码来源:frmCinema.cs

示例14: CreateFunction

 /// summary
 /// �������ݿ⺯��
 /// /summary
 /// param name="functionName"������/param
 /// param name="functionText"��������/param
 public override void CreateFunction(string functionName, string functionText)
 {
     if(functionText != null && functionText.Trim() != "")
     {
         DropFunction(functionName);
         DbHelper helper = new DbHelper();
         helper.ExecuteNonQuery(functionText);
     }
 }
开发者ID:jokingzhou,项目名称:AnJi-DevZoneGIS,代码行数:14,代码来源:DbUtil.cs

示例15: Insert

        public bool Insert(User tModel) {
            using (SqlCommand command = new DbHelper().Command) {
                command.CommandText =
                    "insert into eduuser(userid,userpass,name,age,birthday) values (@userid,@userpass,@name,@age,@birthday)";
                command.Parameters.AddRange(CreateSqlParameters(tModel));
                int ret = command.ExecuteNonQuery();

                return ret > 0;
            }
        }
开发者ID:kangwl,项目名称:DotNet.Mix,代码行数:10,代码来源:UserDal.cs


注:本文中的DbHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。