VB你码如下dim cnn1 as oledbconnection
dim strcnn1="provider=microsoft.jet.oledb.4.0;data source="+server.mappath(ConfigurationSettings.AppSettings("数据库路径"))
dim counts as integer
dim page as string
dim pagesize as integer
dim startnumber as integer
dim pagecount as integer
dim cmd1 as oledbcommand
cnn1=new oledbconnection(strcnn1)
cnn1.open
cmd1=new oledbcommand("select count(id) from leaveword ",cnn1)
counts=cmd1.executescalar()
cnn1.close
page=request.querystring("page")
pagesize=ConfigurationSettings.AppSettings("每页显示数")
if page="" then '当前页码纠错判断
page=1
else
on error resume next
page=cint(page)
if page<1 then page=1 '页码过小时调整为第一页
if page>counts/pagesize then page=fix(counts/pagesize)+1 '页码过大时仅所能调整为最后的一页
end if
startnumber=page*pagesize-pagesize '求分页的记录条起始号码,当前页*1页显示的条数-1页显示的条数
pagecount=fix(counts/pagesize)
if counts mod pagesize<>0 then pagecount+=1 '求得共有多少页(本例有余数则多加一页)
dim i as integer '定义一个游标向前时记数作用的游标
while dr.read()
i+=1:if i-startnumber>pagesize then exit while '输出够pagesize条记录后,EXIT
if i>startnumber then
if page="" then
gogo.text="1"
else
gogo.text=page
end if
%>
怎么谈的上 VB.net => C# 呢?
楼主开玩笑了哇
string strcnn1="provider=microsoft.jet.oledb.4.0;data source="+server.mappath(ConfigurationSettings.AppSettings["数据库路径"]);
int counts = 0;
string page ="";
int pagesize =0;
int startnumber =0;
int pagecount = 0;
oledbcommand cmd1;
cnn1 = new oledbconnection(strcnn1);
cnn1.open();
cmd1=new oledbcommand("select count(id) from leaveword ",cnn1);
counts=cmd1.executescalar();
cnn1.close();
page=Convert.toInt(request.querystring["page"].tostring());
pagesize=Convert.toInt(ConfigurationSettings.AppSettings("每页显示数").tostring());
if page="" then '当前页码纠错判断
page=1
else
on error resume next
page=cint(page)
if page<1 then page=1 '页码过小时调整为第一页
if page>counts/pagesize then page=fix(counts/pagesize)+1 '页码过大时仅所能调整为最后的一页
end if
startnumber=page*pagesize-pagesize '求分页的记录条起始号码,当前页*1页显示的条数-1页显示的条数
pagecount=fix(counts/pagesize)
if counts mod pagesize<>0 then pagecount+=1 '求得共有多少页(本例有余数则多加一页)
dim i as integer '定义一个游标向前时记数作用的游标
while dr.read()
i+=1:if i-startnumber>pagesize then exit while '输出够pagesize条记录后,EXIT
if i>startnumber then
if page="" then
gogo.text="1"
else
gogo.text=page
end if
%>
string strcnn1 ="provider=microsoft.jet.oledb.4.0;data source="+server.mappath(ConfigurationSettings.AppSettings("数据库路径"));
int page1;
int counts ;
string page ;
int pagesize ;
int startnumber;
int pagecount ;
OleDbCommand cmd1;
cnn1=new OleDbConnection(strcnn1);
cnn1.open();
cmd1=new OleDbCommand("select count(id) from leaveword ",cnn1);
counts=cmd1.ExecuteScalar();
cnn1.close();
page=Request.QueryString["page"];
pagesize=ConfigurationSettings.AppSettings("每页显示数");
if( page=="")// 当前页码纠错判断
page1=1;
else
//on error resume next
page1=Convert.ToInt32(page);
if page1<1
page1=1 ; //页码过小时调整为第一页
if (page1>counts/pagesize )
page1=counts/pagesize+1; //页码过大时仅所能调整为最后的一页
startnumber=page*pagesize-pagesize ; //求分页的记录条起始号码,当前页*1页显示的条数-1页显示的条数
pagecount=counts/pagesize;
if (counts %pagesize!=0)
pagecount+=1 //求得共有多少页(本例有余数则多加一页)
int i =0;//定义一个游标向前时记数作用的游标
while (dr.read())
{
i+=1;
if (i-startnumber>pagesize) break;//输出够pagesize条记录后,EXIT
if (i>startnumber)
{if (page="") gogo.text="1";
else
gogo.text=page;
}
%>
随手改的,其中page定义是string的,不知道怎么成了int ,我就又加上int型的page1
object strcnn1 = "provider=microsoft.jet.oledb.4.0;data source=" + server.mappath(ConfigurationSettings.AppSettings("数据库路径"));
int counts;
string page;
int pagesize;
int startnumber;
int pagecount;
oledbcommand cmd1;
private object cnn1 = new oledbconnection(strcnn1);
string strcnn1 = "provider=microsoft.jet.oledb.4.0;data source=" + this.MapPath(ConfigurationSettings.AppSettings("数据库路径"));
int counts;
string page;
int pageno;
int pagesize;
int startnumber;
int pagecount;
OleDbCommand cmd1;
cnn1 = new OleDbConnection(strcnn1);
cnn1.Open();
cmd1 = new OleDbCommand("select count(id) from leaveword ", cnn1);
counts = cmd1.ExecuteScalar();
cnn1.Close();
page = Request.QueryString["page"];
pagesize = ConfigurationSettings.AppSettings("每页显示数");
try
{
if ( page != null && page != string.Empty )
pageno = Convert.ToInt32(page);
else
pageno = 1;
}
catch()
{
pageno = 1;
}pageno = pageno<1 ? 1 : pageno;
pageno = pageno>(counts/pagesize) ? counts/pagesize + 1 : pageno;pagecount = counts/pagesize;
if (counts % pagesize != 0)
pagecount++;后面一个奇怪的dr,不翻了……
oledbconnection cnn1;
string strcnn1="provider=microsoft.jet.oledb.4.0;data source="+server.mappath (ConfigurationSettings.AppSettings("数据库路径"));
int counts;
string page;
int pagesize;
int startnumber;
int pagecount;
oledbcommand cmd1;
cnn1=new oledbconnection(strcnn1);
cnn1.open();
cmd1=new oledbcommand("select count(id) from leaveword ",cnn1);
counts=cmd1.executescalar();
cnn1.close();
page=request.querystring("page");
pagesize=ConfigurationSettings.AppSettings("每页显示数");
if(page.length==0) //当前页码纠错判断
{
page=1;
}
else
{
page=cint(page)
if(page<1) page=1; //页码过小时调整为第一页
if(page>counts/pagesize) page=fix(counts/pagesize)+1; //页码过大时仅所能调整为最后的一页
}
startnumber=page*pagesize-pagesize; //求分页的记录条起始号码,当前页*1页显示的条数-1页显示的条数
pagecount=fix(counts/pagesize);
if(counts mod pagesize<>0) pagecount+=1 //求得共有多少页(本例有余数则多加一页)
int i; //定义一个游标向前时记数作用的游标
while(dr.read())
i+=1;
if(i-startnumber>pagesize) break; '输出够pagesize条记录后,EXIT
if(i>startnumber)
{
if(page.length==0)
gogo.text="1";
else
gogo.text=page;
}