[C#][SQLLITE]一个数据分页技巧

public DataTable GetAccInfoList(string typeId, int beginIndex, int pageSize, out int recordCount)
{
    DataTable dt = null;
    recordCount = 0;
    try
    {
        StringBuilder sb = new StringBuilder();
        sb.Append("select Tab_AccidentCase.[Id],AccTitle,TypeName,IsSystem ");
        sb.Append("from Tab_AccidentCase,Tab_AccidentType where Tab_AccidentCase.[AccType]=Tab_AccidentType.[Id] ");
        if (!string.IsNullOrEmpty(typeId))
            sb.AppendFormat("and AccType='{0}' ", typeId);
        sb.AppendFormat(" limit {0},{1}", beginIndex, pageSize);

        dt = SqliteHelper.Query(sb.ToString(), SysEnum.SysDataBaseName.accb6264f0b4413ab83a416c0c32dff2.ToString());

        string sql = "select count (Id) from Tab_AccidentCase ";
        if (!string.IsNullOrEmpty(typeId))
            sql  = "where AccType="   typeId;

        recordCount = int.Parse(SqliteHelper.GetSingle(sql, SysEnum.SysDataBaseName.accb6264f0b4413ab83a416c0c32dff2.ToString()).ToString());
    }
    catch (Exception ex)
    { throw ex; }
    return dt;
}
posted @ 2012-07-18 16:31  Hsppl  阅读(591)  评论(0编辑  收藏  举报