我用的是vs2010 asp.net c# 数据库是sql server 2000 制作分页,实在不行了。做不出来了。
要求有个信息总数,上一页下一页,我做了一半了,求改下。usingSystem;usingSystem.Collections.Generic;usingSystem.We...
要求有个信息总数,上一页下一页,我做了一半了,求改下。
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
public partial class home_ht_lb : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e) //作用于回复的
{
SqlConnection conn = db.CreatConnection();
conn.Open();
String sql = "select jbxx_id,wt,scsj from jjw_jbxx order by scsj desc";
SqlCommand cmd = new SqlCommand(sql, conn);
//不太明白,请别人写的,可以帮我解释吗
SqlDataAdapter sda = new SqlDataAdapter(cmd);
//建立DataSet对象,加载到jjw_jbxx表中
DataSet ds = new DataSet();
sda.Fill(ds, "jjw_jbxx");
conn.Close();
//显示数据 Datalist控件,显示3个值(好像是)
DataList1.DataSource = ds.Tables["jjw_jbxx"];
DataList1.DataBind();
conn.Close();
}
protected void LinkButton1_Command(object sender, CommandEventArgs e) //作用于删除
{
SqlConnection conn = db.CreatConnection();
conn.Open();
// 取jbxx_id值,知道哪个值后删除
String sql = "delete jjw_jbxx where jbxx_id=" + e.CommandArgument.ToString();
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.ExecuteNonQuery();
conn.Close();
Response.Redirect("home_ht_lb.aspx");
}
} 展开
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
public partial class home_ht_lb : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e) //作用于回复的
{
SqlConnection conn = db.CreatConnection();
conn.Open();
String sql = "select jbxx_id,wt,scsj from jjw_jbxx order by scsj desc";
SqlCommand cmd = new SqlCommand(sql, conn);
//不太明白,请别人写的,可以帮我解释吗
SqlDataAdapter sda = new SqlDataAdapter(cmd);
//建立DataSet对象,加载到jjw_jbxx表中
DataSet ds = new DataSet();
sda.Fill(ds, "jjw_jbxx");
conn.Close();
//显示数据 Datalist控件,显示3个值(好像是)
DataList1.DataSource = ds.Tables["jjw_jbxx"];
DataList1.DataBind();
conn.Close();
}
protected void LinkButton1_Command(object sender, CommandEventArgs e) //作用于删除
{
SqlConnection conn = db.CreatConnection();
conn.Open();
// 取jbxx_id值,知道哪个值后删除
String sql = "delete jjw_jbxx where jbxx_id=" + e.CommandArgument.ToString();
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.ExecuteNonQuery();
conn.Close();
Response.Redirect("home_ht_lb.aspx");
}
} 展开
展开全部
sql server 分页语句
/*
SELECT TOP 页大小 *
FROM TestTable
WHERE (ID NOT IN
(SELECT TOP 页大小*页数 id
FROM 表
ORDER BY id))
ORDER BY ID
SELECT TOP 页大小 *
FROM TestTable
WHERE (ID > (SELECT ISNULL(MAX(id),0)
FROM (SELECT TOP 页大小*页数 id
FROM 表
ORDER BY id) AS T))
ORDER BY ID
*/
/*
SELECT TOP 页大小 *
FROM TestTable
WHERE (ID NOT IN
(SELECT TOP 页大小*页数 id
FROM 表
ORDER BY id))
ORDER BY ID
SELECT TOP 页大小 *
FROM TestTable
WHERE (ID > (SELECT ISNULL(MAX(id),0)
FROM (SELECT TOP 页大小*页数 id
FROM 表
ORDER BY id) AS T))
ORDER BY ID
*/
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
直接用控件写 很简单的 或者去51aspx 上找个demo
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select top num(每页条数) *
from table(表名) where id not int (select top num(每页条数) * 页数 from table(表名)
))
from table(表名) where id not int (select top num(每页条数) * 页数 from table(表名)
))
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询