Access db = new Access();
string str = db.GetString("select count(*) from msg");
int maxrows = string.IsNullOrWhiteSpace(str) ? 0 : Convert.ToInt32(str);
int maxpage = (maxrows % pagecount == 0) ? (maxrows / pagecount) : (maxrows / pagecount + 1);
int lastcount = (maxrows % pagecount == 0) ? (pagecount) : (maxrows % pagecount);
int rang = (maxpage + 1 - pageno) * pagecount;
string sql = "";
if (pageno < maxpage)
{
sql = "select top " + pagecount + " * from (select top " + rang + " * from msg order by id desc) order by id";
}
else
{
sql = "select top " + lastcount + " * from (select top " + lastcount + " * from msg order by id desc) order by id";
}
DataTable dt = db.GetDataTable(sql);
string str = db.GetString("select count(*) from msg");
int maxrows = string.IsNullOrWhiteSpace(str) ? 0 : Convert.ToInt32(str);
int maxpage = (maxrows % pagecount == 0) ? (maxrows / pagecount) : (maxrows / pagecount + 1);
int lastcount = (maxrows % pagecount == 0) ? (pagecount) : (maxrows % pagecount);
int rang = (maxpage + 1 - pageno) * pagecount;
string sql = "";
if (pageno < maxpage)
{
sql = "select top " + pagecount + " * from (select top " + rang + " * from msg order by id desc) order by id";
}
else
{
sql = "select top " + lastcount + " * from (select top " + lastcount + " * from msg order by id desc) order by id";
}
DataTable dt = db.GetDataTable(sql);