zoukankan      html  css  js  c++  java
  • 在做web项目时经常遇到新闻要上一篇,下一篇

    代码
    上一篇
    create proc Prev
    (
      @ID
    )
    as
    declare @Record
    int
    set @Record = (select count(ID) from News where ID<@ID)
    if @Record>0
    begin
    select top
    1 ID from News where ID<@ID order by ID desc
    end
    else
    begin
    select max(ID) from News
    end
    下一篇
    create proc Next
    (
      @ID
    )
    as
    declare @Record
    int
    set @Record = (select count(ID) from News where ID>@ID)
    if @Record>0
    begin
    select top
    1 ID from News where ID>@ID
    end
    else
    begin
    select min(ID) from News
    end














    aspnet 上一篇下一篇代码2010
    -03-02 16:43<div style="float: left; 316px; line-height: 25px; height: 25px; margin-left: 2px;">
    下一篇:
    <asp:HyperLink ID="HyperLink1" runat="server">[HyperLink1]</asp:HyperLink>
    </div>
    <div style="float: right; 316px; line-height: 25px; height: 25px">
    上一篇:
    <asp:HyperLink ID="HyperLink2" runat="server">[HyperLink2]</asp:HyperLink></div>
    public void next()
    {
    string t_id = Request.QueryString["id"].ToString();
    string sql = "select top 1 title,id from content where id>'" + t_id;
    DataSet dr
    = xgl.databind(sql);
    if (ds.Tables[0].Rows.Count > 0)
    {
    DataRow dr
    = xgl.databind(sql).Tables[0].Rows[0];
    this.HyperLink1.Text = SubStr(dr["title"].ToString(), 20);
    this.HyperLink1.NavigateUrl = "e" + dr["id"].ToString() + ".aspx";
    }
    else
    {
    this.HyperLink1.Text = "没有下一篇!";
    }

    }

    public void Pre()
    {
    string t_id = Request.QueryString["id"].ToString();
    SqlConnection conn
    = new SqlConnection(ConfigurationManager.AppSettings["ConSql"]);
    conn.Open();
    SqlCommand sqlCmd1
    = new SqlCommand("select top 1 title,id from content where id<'" + t_id + "'", conn);
    SqlDataReader dr1
    = sqlCmd1.ExecuteReader();
    if (dr1.Read())
    {
    this.HyperLink2.Text = SubStr(dr1["title"].ToString(), 20);
    this.HyperLink2.NavigateUrl = "e" + dr1["id"].ToString() + ".aspx";
    }
    else
    {
    this.HyperLink2.Text = "没有上一篇!";
    }
    sqlCmd1.Dispose();
    conn.Close();
    }


  • 相关阅读:
    PHP工具下载地址
    Eclipse开发PHP环境配置
    Windows下搭建PHP开发环境
    无插件Vim编程技巧
    mvn详解
    Python读写文件
    python 大文件以行为单位读取方式比对
    insert时出现主键冲突的处理方法【转载】
    Python机器学习——线性模型
    机器学习算法与Python实践之(七)逻辑回归(Logistic Regression)
  • 原文地址:https://www.cnblogs.com/lilo202/p/1864204.html
Copyright © 2011-2022 走看看