/// <summary>
/// 对电影进行分页(这里用sql效率比较高)
/// </summary>
/// <param name="myPageSize">每页显示的条数</param>
/// <param name="myPageIndex">读取第几页</param>
/// <param name="typeId">类别Id</param>
/// <returns></returns>
public DataSet PageFilms(int myPageSize,int myPageIndex,int typeId)
{
string condition = "typeID>0";
if (typeId>0)
condition = "typeID=" + typeId.ToString();
string sql = "select top "+myPageSize+" id,name,fromCountry,director,players, hits, typeId,pDate from films where "+condition+" order by id DESC ";
//如果当前页码不为0
if (myPageIndex > 1)
//效率太低,所以改用下面的语句
// sql = "select top " + myPageSize + " id,name,fromCountry,director,players, hits, typeId,pDate from films where id not in (select top " + (myPageSize - 1) * myPageIndex + " id from films order by id DESC) order by id DESC";
sql = "select top " + myPageSize + " id,name,fromCountry,director,players, hits, typeId,pDate from films where id < (Select Min(id) from(select top " + (myPageSize - 1) * myPageIndex + " id from films order by id DESC) as T) and "+condition+" order by id DESC";
OleDbCommand cmd = new OleDbCommand(sql,dbConn.conn);
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataSet ds = null;
try
{
dbConn.Open();
&nb |