.net读取数据库分页方法汇总

        /// <summary>
        /// .net自带分页方法
        /// </summary>
        /// <param name="PageSize"></param>
        /// <param name="PageIndex"></param>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public static DataSet RunProcedure(int PageSize, int PageIndex, string strWhere)
        {
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                DataSet ds = new DataSet();
                try
                {
                    connection.Open();
                    SqlDataAdapter command = new SqlDataAdapter(strWhere, connection);
                    command.Fill(ds, PageIndex, PageSize, strWhere);
                }
                catch (System.Data.SqlClient.SqlException ex)
                {
                    throw new Exception(ex.Message);
                }
                return ds;
            }
        }





 

posted @ 2013-04-02 15:03  xyzhuzhou  阅读(313)  评论(0编辑  收藏  举报