/// <summary>
/// 技术支持分页展示
/// </summary>
/// <param name="pagesize">每页显示多少条</param>
/// <param name="pageindex">当前第几页</param>
/// <returns>返回List<prod_news>集合</returns>
public List<T_News> T_News_FenYe(int pagesize, int pageindex)
{
try
{
int num = pagesize * pageindex;
string sqlStr = "select top 16 * from T_News where InfoID not in (select top " + num + " InfoID from T_News order by InfoID desc) order by InfoID desc where ClsID=4 ";
OleDbCommand cmd = new OleDbCommand(sqlStr, con);
OleDbParameter par1 = new OleDbParameter("@pagesize", OleDbType.Integer);
OleDbParameter par2 = new OleDbParameter("@pageindex", OleDbType.Integer);
par1.Value = pagesize;
par2.Value = pageindex;
cmd.Parameters.Add(par1);
cmd.Parameters.Add(par2);
List<T_News> list = new List<T_News>();
con.Open();
OleDbDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
T_News T_News = new T_News();
T_News.InfoID = Convert.ToInt32(reader["InfoID"]);
T_News.ClsID = Convert.ToInt32(reader["ClsID"]);
T_News.InfoName = reader["InfoName"].ToString();
T_News.InfoNote = reader["InfoNote"].ToString();
T_News.InfoDate = Convert.ToDateTime(reader["InfoDate"]);
T_News.Hits = Convert.ToInt32(reader["Hits"]);
T_News.writefrom = reader["writefrom"].ToString();
T_News.Istuijian = Convert.ToInt32(reader["Istuijian"]);
list.Add(T_News);
}
return list;
}
本人初次使用ACCESS 望指点~
------解决方案--------------------------------------------------------
where InfoID not in (select top " + num + " InfoID from T_News order by InfoID desc) order by InfoID desc where ClsID=4
后面一个where 改为and