Access开发培训
网站公告
·Access专家课堂QQ群号:151711184    ·Access快速开发平台下载地址及教程    ·欢迎加入Access专家课堂微信群!    ·如何快速搜索本站文章|示例|资料    
您的位置: 首页 > 技术文章 > 综合其它

access下的分页方案

时 间:2008-07-15 13:25:14
作 者:umvsoft整理   ID:16  城市:江阴
摘 要:access下的分页方案
正 文:

具体不多说了,只贴出相关源码~

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;
using System.Web;

/**//// <summary>
/// 名称:access下的分页方案(仿sql存储过程)
/// 作者:cncxz(虫虫)
/// blog:http://cncxz.cnblogs.com
/// </summary>
public class AdoPager
{
    protected string m_ConnString;
    protected OleDbConnection m_Conn;

    public AdoPager()
    {
        CreateConn(string.Empty);
    }
    public AdoPager(string dbPath)
    {
        CreateConn(dbPath);
    }

    private void CreateConn(string dbPath)
    {
        if (string.IsNullOrEmpty(dbPath))
        {
            string str = System.Configuration.ConfigurationManager.AppSettings["dbPath"] as string;
            if (string.IsNullOrEmpty(str))
                str = "~/App_Data/db.mdb";
            m_ConnString = string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data source={0}", HttpContext.Current.Server.MapPath(str));
        }
        else
            m_ConnString = string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data source={0}", dbPath);

        m_Conn = new OleDbConnection(m_ConnString);
    }
    /**//// <summary>
    /// 打开连接
    /// </summary>
    public void ConnOpen()
    {
        if (m_Conn.State != ConnectionState.Open)
            m_Conn.Open();
    }
    /**//// <summary>
    /// 关闭连接
    /// </summary>
    public void ConnClose()
    {
        if (m_Conn.State != ConnectionState.Closed)
            m_Conn.Close();
    }

    private string recordID(string query, int passCount)
    {
        OleDbCommand cmd = new OleDbCommand(query, m_Conn);
        string result = string.Empty;
        using (IDataReader dr = cmd.ExecuteReader())
        {
            while (dr.Read())
            {
                if (passCount < 1)
                {
                    result += "," + dr.GetInt32(0);
    &n

Access软件网QQ交流群 (群号:54525238)       Access源码网店


常见问答:

技术分类:

相关资源:

专栏作家

关于我们 | 服务条款 | 在线投稿 | 友情链接 | 网站统计 | 网站帮助