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


C# DbHelper.ExecuteReader方法代码示例

本文整理汇总了C#中DbHelper.ExecuteReader方法的典型用法代码示例。如果您正苦于以下问题:C# DbHelper.ExecuteReader方法的具体用法?C# DbHelper.ExecuteReader怎么用?C# DbHelper.ExecuteReader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DbHelper的用法示例。


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

示例1: 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

示例2: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["uname"] == null)
     {
         Response.Write("<script>alert('系统超时或非法登录,请重新登录!');window.location.href='default.aspx';</script>");
     }
     dbh = new DbHelper();
     string sql;
     sql = string.Format("select * from version" );
     DbCommand dbc = dbh.GetSqlStringCommond(sql);
     dbr = dbh.ExecuteReader(dbc);
     this.GridView1.DataSource = dbr;
     this.GridView1.DataBind();
 }
开发者ID:wangshu,项目名称:printv2,代码行数:14,代码来源:Versioninfo.aspx.cs

示例3: GetCustomObjects

        /// <summary>
        /// 获取数据库中的所有自定义对象。
        /// </summary>
        /// <param name="databaseName">数据库名称</param>
        /// <returns>自定义对象名称集合</returns>
        public override IList<CustomObject> GetCustomObjects(string databaseName)
        {
            var result = new List<CustomObject>();
            var dbUtil = new DbHelper(MYSQL_PROVIDER, string.Format(MYSQL_CONNECTION_FORMAT, this.ServerUri, this.Account, this.Password, databaseName));

            var reader = dbUtil.ExecuteReader("show TABLES");

            while (reader.Read())
            {
                result.Add(new CustomObject { Name = reader.GetString(0) });
            }

            return result;
        }
开发者ID:fenglinz,项目名称:Sparrow,代码行数:19,代码来源:MySQLMetadata.cs

示例4: GetDatabaseNames

        /// <summary>
        /// 获取数据库名称集合。
        /// </summary>
        /// <returns>数据库名称集合</returns>
        public override IList<string> GetDatabaseNames()
        {
            var result = new List<string>();
            var dbUtil = new DbHelper(MYSQL_PROVIDER, string.Format(MYSQL_CONNECTION_FORMAT, this.ServerUri, this.Account, this.Password, "mysql"));

            var reader = dbUtil.ExecuteReader("show DATABASES");

            while (reader.Read())
            {
                result.Add(reader.GetString(0));
            }

            return result;
        }
开发者ID:fenglinz,项目名称:Sparrow,代码行数:18,代码来源:MySQLMetadata.cs

示例5: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Form["uname"] == null)
        {
            Response.Write("<script>alert('系统超时或非法登录,请重新登录!');window.location.href='default.aspx';</script>");
            return;
        }
        if (Request.Form["psw"] == null)
        {
            Response.Write("<script>alert('系统超时或非法登录,请重新登录!');window.location.href='default.aspx';</script>");
            return;
        }
        DbHelper dbh = new DbHelper();
        string user = Request.Form["uname"];
        string psw = Request.Form["psw"];
        string sql = "select count(*) as c from admin where [email protected] and [email protected]";
        DbCommand cmd = dbh.GetSqlStringCommond(sql);
        SqlParameter[] dbp = new SqlParameter[2];
        dbp[0] = new SqlParameter();
        dbp[0].ParameterName = "@u";
        dbp[0].Value = user;
        dbp[1] = new SqlParameter();
        dbp[1].ParameterName = "@p";
        dbp[1].Value = psw;
        sql = dbh.ExecuteScalar(cmd, dbp).ToString();
        if (sql != "1")
        {
            Response.Write("<script>alert('用户名密码错误,请重新输入!');window.location.href='default.aspx';</script>");

        }
        else
        {
            Session.Timeout = 30;
             sql = "select * from admin where username='"+user+"' and password='"+psw +"'";
            DbCommand cmd2 = dbh.GetSqlStringCommond(sql);
            DbDataReader dr = dbh.ExecuteReader(cmd2);
            dr.Read();
            Session["uname"] = user;
            Session["uid"] = dr["id"].ToString();
            Session["ucount"] = dr["usercount"].ToString();
            Response.Write("<script> window.location.href='userlist.aspx';</script>");
        }
    }
开发者ID:wangshu,项目名称:printv2,代码行数:43,代码来源:main.aspx.cs

示例6: GetTableOrViewDetails

        /// <summary>
        /// 获取表或视图的详细信息。
        /// </summary>
        /// <param name="databaseName">数据库名称</param>
        /// <param name="tableName">表或视图名称</param>
        /// <param name="isView">是否为视图</param>
        /// <returns>表或视图信息</returns>
        public override DbTable GetTableOrViewDetails(string databaseName, string tableName, bool isView = false)
        {
            var result = new DbTable();
            var dbUtil = new DbHelper(MYSQL_PROVIDER, string.Format(MYSQL_CONNECTION_FORMAT, this.ServerUri, this.Account, this.Password, databaseName));

            result.Name = tableName;
            result.ClassName = tableName.AsClassName();
            result.Description = result.ClassName;

            try
            {
                using (var reader = dbUtil.ExecuteReader(string.Format("DESC {0}", tableName)))
                {
                    while (reader.Read())
                    {
                        var field = new DbColumn
                        {
                            Name = reader.GetString(0),
                            PropertyName = reader.GetString(0).PascalNaming(),
                            IsIdentity = !Convert.IsDBNull(reader[5]) && reader.GetString(5).Contains("auto_increment"),
                            IsPrimaryKey = !Convert.IsDBNull(reader[3]) && reader.GetString(3).ToUpper().Contains("PRI"),
                            Nullable = reader.GetString(2) == "YES",
                            Description = reader.GetString(0),
                        };

                        var sqlType = reader.GetString(1).Split(' ')[0];

                        if (sqlType.Contains('('))
                        {
                            sqlType = sqlType.Substring(0, sqlType.IndexOf('('));
                        }

                        field.SqlType = sqlType;
                        field.BasicType = sqlType;

                        result.Columns.Add(field);
                    }
                }
            }
            catch { }

            return result;
        }
开发者ID:fenglinz,项目名称:Sparrow,代码行数:50,代码来源:MySQLMetadata.cs


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