存储过程如下:
@pagesize int ,--每页记录数
@currentpage int,--当前页
@wh_month varchar(15),--维护月份
@wh_baoyang varchar(20),--保养要求
@pagecount int output,--总记录数
@pages int output--总页数AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
declare @page int
declare @sql nvarchar(1000) declare @numtemp int
-- Insert statements for procedure here
/*set @sql='select @pc= count(*) from (select B_device.zichannum,b_device.baoyang,b_device.devicename,
b_device.cfadress,weihu_v.wh_date,weihu_v.wh_id,wh_danhao from weihu_v left outer join B_device on
weihu_v.zch_num= b_device.zichannum) #temptable where wh_id<>'''' and baoyang like ''%'+@wh_baoyang+'%'' and wh_date like ''%'+@wh_month+'%'' '
exec sp_executesql @sql,N'@pc int output',@page output*/
select @pagecount=count(*) from wh_JH where wh_id<>'' and baoyang like @wh_baoyang and wh_date like @wh_month if @pagecount=0
begin
set @pages=1
end
else
begin
set @numtemp=@pagecount%@pagesize
if @numtemp=0
begin
set @pages=(@pagecount/@pagesize)
end
else
begin
set @pages=@pagecount/@pagesize+1
end
end
--if @currentpage=1
--begin
select * from (select top ((@currentpage)*(@pagesize)) row_number()over(order by wh_id desc)id , * from wh_JH where wh_id<>'' and baoyang like @wh_baoyang and wh_date like @wh_month)t where id>((@currentpage-1)*(@pagesize)) order by wh_id desc
cs代码如下:
protected void BindDataList(int pindex)
{
// Response.Write("{0} {1} {2}{3}", PDS.PageSize, Convert.ToInt32(curpage.Text), year.SelectedItem.Text + DropDownList1.SelectedItem.Text,DropDownList4.SelectedItem.Text);
SqlCommand Command = new SqlCommand();
PagedDataSource PDS = new PagedDataSource();
PDS.AllowPaging = true;
PDS.PageSize = 15; if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
Command.Connection = conn;
Command.CommandType = CommandType.StoredProcedure;
Command.CommandText = "WH_finishpage"; SqlParameter page = new SqlParameter("@pagesize", SqlDbType.Int);
page.Value = PDS.PageSize;
Command.Parameters.Add(page); SqlParameter current = new SqlParameter("@currentpage", SqlDbType.Int);
current.Value = pindex;
Command.Parameters.Add(current); SqlParameter month = new SqlParameter("@wh_month", SqlDbType.VarChar, 20);
month.Value ="%"+ year.SelectedItem.Text + "-" + DropDownList1.SelectedItem.Text+"%";
Command.Parameters.Add(month); SqlParameter baoyang = new SqlParameter("@wh_baoyang", SqlDbType.VarChar, 20);
baoyang.Value ="%"+ DropDownList4.SelectedItem.Text+"%";
Command.Parameters.Add(baoyang); SqlParameter pcount = new SqlParameter("@pagecount", SqlDbType.Int);
Command.Parameters.Add(pcount);
Command.Parameters["@pagecount"].Direction = ParameterDirection.Output;
SqlParameter ppges = new SqlParameter("@pages", SqlDbType.Int);
Command.Parameters.Add(ppges);
Command.Parameters["@pages"].Direction = ParameterDirection.Output;
PDS.CurrentPageIndex = pindex - 1; SqlDataAdapter adapter=new SqlDataAdapter();
adapter.SelectCommand=Command;
DataSet ds=new DataSet();
adapter.Fill(ds);
this.nextpage.Enabled = true;
this.provepage.Enabled = true;
this.firstpage.Enabled = true;
this.lastpage.Enabled = true;
pagecount.Text =pcount.Value.ToString();
// PDS.PageCount = pcount.Value;
pages.Text = ppges.Value.ToString();
if (curpage.Text == "1")
{
this.provepage.Enabled = false;
this.firstpage.Enabled = false; }
if (curpage.Text == pages.Text)
{
this.nextpage.Enabled = false;
this.lastpage.Enabled = false;
}
PDS.DataSource = ds.Tables[0].DefaultView;
this.DataList2.DataSource=PDS;
this.DataList2.DataKeyField = "zichannum";
this.DataList2.DataBind();
conn.Close();
}
哪位高手帮忙看看
@pagesize int ,--每页记录数
@currentpage int,--当前页
@wh_month varchar(15),--维护月份
@wh_baoyang varchar(20),--保养要求
@pagecount int output,--总记录数
@pages int output--总页数AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
declare @page int
declare @sql nvarchar(1000) declare @numtemp int
-- Insert statements for procedure here
/*set @sql='select @pc= count(*) from (select B_device.zichannum,b_device.baoyang,b_device.devicename,
b_device.cfadress,weihu_v.wh_date,weihu_v.wh_id,wh_danhao from weihu_v left outer join B_device on
weihu_v.zch_num= b_device.zichannum) #temptable where wh_id<>'''' and baoyang like ''%'+@wh_baoyang+'%'' and wh_date like ''%'+@wh_month+'%'' '
exec sp_executesql @sql,N'@pc int output',@page output*/
select @pagecount=count(*) from wh_JH where wh_id<>'' and baoyang like @wh_baoyang and wh_date like @wh_month if @pagecount=0
begin
set @pages=1
end
else
begin
set @numtemp=@pagecount%@pagesize
if @numtemp=0
begin
set @pages=(@pagecount/@pagesize)
end
else
begin
set @pages=@pagecount/@pagesize+1
end
end
--if @currentpage=1
--begin
select * from (select top ((@currentpage)*(@pagesize)) row_number()over(order by wh_id desc)id , * from wh_JH where wh_id<>'' and baoyang like @wh_baoyang and wh_date like @wh_month)t where id>((@currentpage-1)*(@pagesize)) order by wh_id desc
cs代码如下:
protected void BindDataList(int pindex)
{
// Response.Write("{0} {1} {2}{3}", PDS.PageSize, Convert.ToInt32(curpage.Text), year.SelectedItem.Text + DropDownList1.SelectedItem.Text,DropDownList4.SelectedItem.Text);
SqlCommand Command = new SqlCommand();
PagedDataSource PDS = new PagedDataSource();
PDS.AllowPaging = true;
PDS.PageSize = 15; if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
Command.Connection = conn;
Command.CommandType = CommandType.StoredProcedure;
Command.CommandText = "WH_finishpage"; SqlParameter page = new SqlParameter("@pagesize", SqlDbType.Int);
page.Value = PDS.PageSize;
Command.Parameters.Add(page); SqlParameter current = new SqlParameter("@currentpage", SqlDbType.Int);
current.Value = pindex;
Command.Parameters.Add(current); SqlParameter month = new SqlParameter("@wh_month", SqlDbType.VarChar, 20);
month.Value ="%"+ year.SelectedItem.Text + "-" + DropDownList1.SelectedItem.Text+"%";
Command.Parameters.Add(month); SqlParameter baoyang = new SqlParameter("@wh_baoyang", SqlDbType.VarChar, 20);
baoyang.Value ="%"+ DropDownList4.SelectedItem.Text+"%";
Command.Parameters.Add(baoyang); SqlParameter pcount = new SqlParameter("@pagecount", SqlDbType.Int);
Command.Parameters.Add(pcount);
Command.Parameters["@pagecount"].Direction = ParameterDirection.Output;
SqlParameter ppges = new SqlParameter("@pages", SqlDbType.Int);
Command.Parameters.Add(ppges);
Command.Parameters["@pages"].Direction = ParameterDirection.Output;
PDS.CurrentPageIndex = pindex - 1; SqlDataAdapter adapter=new SqlDataAdapter();
adapter.SelectCommand=Command;
DataSet ds=new DataSet();
adapter.Fill(ds);
this.nextpage.Enabled = true;
this.provepage.Enabled = true;
this.firstpage.Enabled = true;
this.lastpage.Enabled = true;
pagecount.Text =pcount.Value.ToString();
// PDS.PageCount = pcount.Value;
pages.Text = ppges.Value.ToString();
if (curpage.Text == "1")
{
this.provepage.Enabled = false;
this.firstpage.Enabled = false; }
if (curpage.Text == pages.Text)
{
this.nextpage.Enabled = false;
this.lastpage.Enabled = false;
}
PDS.DataSource = ds.Tables[0].DefaultView;
this.DataList2.DataSource=PDS;
this.DataList2.DataKeyField = "zichannum";
this.DataList2.DataBind();
conn.Close();
}
哪位高手帮忙看看
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货