string strSql="Select Top "+PageSize+" * from TBLNEWS where ID not in(select top "+PageSize*CurrentPage+" ID from TBLNEWS order by id asc) order by id asc";
这是根据ID分页的   这个能够通过但项目要求通过分类名称(CatalogName)来分页,然后我就把代码改成
string strSql="Select Top "+PageSize+" * from TBLNEWS where CatalogName like '"+this.m_strName+"%' not in(select top "+PageSize*CurrentPage+" CatalogName like '"+this.m_strName+"%' from TBLNEWS order by id asc) order by id asc";
很不幸,抱错,调试说数据库里没数据之后我改成string strSql = "select * from TBLNEWS where CatalogName like '"+this.m_strName+"%'";
这个只是把分类的查出来,根本没实现分页功能this.m_strName为接收CatalogName的参数

解决方案 »

  1.   

    string strSql="Select Top "+PageSize+" * from TBLNEWS where CatalogName like '"+this.m_strName+"%' and ID not in(select top "+PageSize*CurrentPage+" ID from TBLNEWS where CatalogName like '"+this.m_strName+"%' order by id asc) order by id asc"; 
      

  2.   

    先把拼接好的sql语句到查询分析器里试试
      

  3.   

    哥们,不可能搞到查询分析器里面啊,里面有参数this.m_strName
      

  4.   

    据我所知 把你需要的东西全部查出来 同时查一个 rownum 的东西
    然后再根据你需要列进行group by 当然 这时候需要控制rownum
      

  5.   

    这个问题让高手见笑了,其实发现错误后,觉得问题很幼稚,哎呀,sql以后要加强了啊