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


C# DBHelper.ExecuteDataTable方法代码示例

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


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

示例1: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            #region 标签信息
            string strTagInfo = "";

            try
            {
                string sql = "select * from [tb_tag] where tag_ispublic=1";
                DataTable dt = new DataTable();
                DBHelper dbh = new DBHelper(config.DBConn);
                dt = dbh.ExecuteDataTable("", sql);

                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        strTagInfo += "<a href=\"default.aspx?id=" + dt.Rows[i]["tag_id"].ToString() + "\" class=\"tag\" target=\"_blank\">" + dt.Rows[i]["tag_name"].ToString() + "</a>";
                    }
                }

                dbh.Dispose();
                dt.Dispose();
            }
            catch (Exception ex)
            {
                strTagInfo = ex.ToString();
            }

            this.tagBall.InnerHtml = strTagInfo;

            #endregion
        }
开发者ID:juxiaoqi,项目名称:LongmaoSite,代码行数:32,代码来源:tags.aspx.cs

示例2: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string sql = "";

                switch (ControlType)
                {
                    case "1":
                        sql = "delete from [tb_site_user] where su_siteid='" + SiteID + "' and su_userid=" + Class_UserLogin.UserID() + ";insert into [tb_site_user] (su_siteid,su_userid)values('" + SiteID + "'," + Class_UserLogin.UserID() + ") ";
                        break;
                    case "2":
                        sql = "delete from [tb_site_user] where su_siteid='" + SiteID + "' and su_userid=" + Class_UserLogin.UserID() + "";
                        break;
                    case "3":
                        if (Class_UserLogin.IsManageUser())
                        {
                            if (SiteImgURL != "" && SiteImgURL != null)
                            {
                                sql = "update [tb_site] set site_name='" + SiteName + "',site_url='" + SiteURL + "',site_img='" + SiteImgURL + "' where site_id='" + SiteID + "'";
                            }
                        }
                        else
                        {
                            sql = "update [tb_site] set site_name='" + SiteName + "',site_url='" + SiteURL + "' where site_id='" + SiteID + "' and site_ispublic=0";
                        }

                        sql += "delete from [tb_site_tag] where st_siteid='" + SiteID + "';";

                        if (SiteTags.Length > 0)
                        {
                            for (int i = 0; i < SiteTags.Split(',').Count() - 1; i++)
                            {
                                sql += "insert into [tb_site_tag] (st_siteid,st_tagid)values('" + SiteID + "','" + SiteTags.Split(',')[i].ToString() + "');";
                            }
                        }
                        break;
                }

                DataTable dt = new DataTable();
                DBHelper dbh = new DBHelper(config.DBConn);
                dt = dbh.ExecuteDataTable("", sql);

                Response.Write("yes");
            }
            catch
            {
                Response.Write("no");
            }
        }
开发者ID:juxiaoqi,项目名称:LongmaoSite,代码行数:50,代码来源:fav.aspx.cs

示例3: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            #region 标签信息
            string strTagInfo = "";
            string strTagID = "0";
            strTagID = TagID;

            strTagInfo += "<ul class=\"nav nav-tabs nav-stacked\">";

            if (Class_UserLogin.IsLogin())
            {
                if (strTagID == "0" || strTagID == null)
                {
                    strTagInfo += "<li class=\"active\"><a href=\"myfav.aspx\">我的收藏</a></li>";
                }
                else
                {
                    strTagInfo += "<li><a href=\"myfav.aspx\">我的收藏</a></li>";
                }
            }
            else
            {
                if (strTagID == "0" || strTagID == null)
                {
                    strTagID = "8";
                }
            }

            try
            {
                string sql = "select top 10 * from [tb_tag] where tag_ispublic=1 order by tag_order desc";
                DataTable dt = new DataTable();
                DBHelper dbh = new DBHelper(config.DBConn);
                dt = dbh.ExecuteDataTable("", sql);

                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[i]["tag_id"].ToString() == strTagID)
                        {
                            strTagInfo += "<li class=\"active\"><a href=\"default.aspx?id=" + dt.Rows[i]["tag_id"].ToString() + "\">" + dt.Rows[i]["tag_name"].ToString() + "</a></li>";
                        }
                        else
                        {
                            strTagInfo += "<li><a href=\"default.aspx?id=" + dt.Rows[i]["tag_id"].ToString() + "\">" + dt.Rows[i]["tag_name"].ToString() + "</a></li>";
                        }

                    }
                }

                dbh.Dispose();
                dt.Dispose();
            }
            catch (Exception ex)
            {
                strTagInfo = ex.ToString();
            }

            strTagInfo += "<li><a href=\"tags.aspx\">全部标签</a></li>";

            strTagInfo += "</ul>";
            #endregion

            #region 站点信息

            string strSiteInfo = "";
            try
            {
                string sql = "select * from [tb_site]";

                if (Class_UserLogin.IsLogin())
                {
                    if (strTagID == "0" || strTagID == null)
                    {
                        sql = "select a.*,b.* from [tb_site] a,[tb_site_user] b where a.site_id=b.su_siteid and b.su_userid='" + Class_UserLogin.UserID().ToString() + "'";
                    }
                    else
                    {
                        sql = "select e.* from (select a.*,d.su_id  from [tb_site] a left join  [tb_site_user] d on d.su_userid='" + Class_UserLogin.UserID().ToString() + "' and a.site_id=d.su_siteid) as e,[tb_site_tag] b,[tb_tag] c where e.site_id=b.st_siteid and c.tag_id=b.st_tagid and e.site_ispublic=1 and c.tag_ispublic=1 and c.tag_id='" + strTagID + "' order by e.su_id desc,e.site_id asc";
                    }
                }
                else
                {
                    sql = "select a.* from [tb_site] a,[tb_site_tag] b,[tb_tag] c where a.site_id=b.st_siteid and c.tag_id=b.st_tagid and a.site_ispublic=1 and c.tag_ispublic=1 and c.tag_id='" + strTagID + "' order by a.site_id asc";
                }

                DataTable dt = new DataTable();
                DBHelper dbh = new DBHelper(config.DBConn);
                dt = dbh.ExecuteDataTable("", sql);

                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        strSiteInfo += "<div class=\"topic_hot_list span5\"><a target=\"_blank\" href=\"" + dt.Rows[i]["site_url"].ToString() + "\" class=\"icon pull-left\"><img src=\"" + dt.Rows[i]["site_img"].ToString() + "\"></a><a target=\"_blank\" class=\"title\" href=\"" + dt.Rows[i]["site_url"].ToString() + "\">" + dt.Rows[i]["site_name"].ToString() + "</a>";
                        if (Class_UserLogin.IsLogin())
                        {
                            if (dt.Rows[i]["su_id"].ToString() == null || dt.Rows[i]["su_id"].ToString() == "")
                            {
//.........这里部分代码省略.........
开发者ID:juxiaoqi,项目名称:LongmaoSite,代码行数:101,代码来源:default.aspx.cs

示例4: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Class_UserLogin.IsLogin())
            {
                Response.Redirect("login.aspx?url=myadd.aspx");
            }

            if (strPost == "yes")
            {
                try
                {
                    string sql = "declare @newid as int;insert into tb_site(site_name,site_url,site_img,site_isopen,site_ispublic,site_createtime)values('" + SiteName + "','" + SiteURL + "','',1,0,'" + DateTime.Now.ToString() + "');set @[email protected]@IDENTITY;insert into tb_site_user(su_siteid,su_userid,su_createtime)values(@newid," + Class_UserLogin.UserID() + ",'" + DateTime.Now.ToString() + "');SELECT @@IDENTITY;";
                    DataTable dt = new DataTable();
                    DBHelper dbh = new DBHelper(config.DBConn);
                    dt = dbh.ExecuteDataTable("", sql);
                    dbh.Dispose();
                    dt.Dispose();
                    this.addinfo.InnerHtml = "提交成功!";
                    this.addinfo.Style.Remove("display");
                }
                catch { }
            }
        }
开发者ID:juxiaoqi,项目名称:LongmaoSite,代码行数:23,代码来源:myadd.aspx.cs

示例5: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            #region 判断用户是否登录
            if (!Class_UserLogin.IsLogin())
            {
                Response.Redirect("login.aspx?url=myfav.aspx");
            }
            #endregion

            #region 站点信息

            string strSiteInfo = "";
            try
            {
                string sql = "select a.* from [tb_site] a,[tb_site_user] b where a.site_id=b.su_siteid and b.su_userid='" + Class_UserLogin.UserID().ToString() + "'";

                DataTable dt = new DataTable();
                DBHelper dbh = new DBHelper(config.DBConn);
                dt = dbh.ExecuteDataTable("", sql);

                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        strSiteInfo += "<div class=\"topic_hot_list span5\"><a target=\"_blank\" href=\"" + dt.Rows[i]["site_url"].ToString() + "\" class=\"icon pull-left\"><img src=\"" + dt.Rows[i]["site_img"].ToString() + "\"></a><a target=\"_blank\" class=\"title\" href=\"" + dt.Rows[i]["site_url"].ToString() + "\">" + dt.Rows[i]["site_name"].ToString() + "</a>";

                        if (dt.Rows[i]["site_ispublic"].ToString() == "0")
                        {
                            strSiteInfo += "<a href=\"javascript:config_control('" + dt.Rows[i]["site_id"].ToString() + "');\" data-id=\"" + dt.Rows[i]["site_id"].ToString() + "\" class=\"config\"></a>";
                        }

                        strSiteInfo += "<a href=\"javascript:fav_control('" + dt.Rows[i]["site_id"].ToString() + "');\" data-id=\"" + dt.Rows[i]["site_id"].ToString() + "\" class=\"followed follow\"></a>";

                        strSiteInfo += "</div>";
                    }
                }
                else
                {
                }

                dbh.Dispose();
                dt.Dispose();
            }
            catch (Exception ex)
            {
                strSiteInfo = ex.ToString();
            }

            this.myfavsite.InnerHtml = strSiteInfo;
            #endregion

            #region 标签信息
            string strTagInfo = "";

            try
            {
                string sql = "select * from [tb_tag] where tag_ispublic=1";
                DataTable dt = new DataTable();
                DBHelper dbh = new DBHelper(config.DBConn);
                dt = dbh.ExecuteDataTable("", sql);

                if (dt.Rows.Count > 0)
                {
                    strTagInfo += "<ul>";
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        strTagInfo += "<li style=\"float:left;margin-right:15px;\"><input id=\"tag" + dt.Rows[i]["tag_id"].ToString() + "\" name=\"tagcheck\" value=\"" + dt.Rows[i]["tag_id"].ToString() + "\" class=\"input-medium\" type=\"checkbox\"> <label for=\"tag" + dt.Rows[i]["tag_id"].ToString() + "\">" + dt.Rows[i]["tag_name"].ToString() + "</label><li>";
                    }
                    strTagInfo += "</ul>";
                }

                dbh.Dispose();
                dt.Dispose();
            }
            catch (Exception ex)
            {
                strTagInfo = ex.ToString();
            }

            this.sitetags.InnerHtml = strTagInfo;

            #endregion
        }
开发者ID:juxiaoqi,项目名称:LongmaoSite,代码行数:83,代码来源:myfav.aspx.cs


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