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

namespace MVC
{
    /**
     *      string connStr = Server.MapPath("/Data/NWind_CHS.mdb");
            string productSql = string.Format("SELECT * From 产品 where 产品ID = {0}", productId);
            Access dl = new Access(connStr);
     * */
    public class Access
    {
        private DataSet dataSetData;
        private OleDbConnection conn;

        public Access(string path)
        {
            string connStr = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};", path);
            conn = new OleDbConnection(connStr);
            dataSetData = new DataSet();
        }

        public DataTable ExecuteDataset(string productSql)
        {
            OleDbCommand cmd = new OleDbCommand(productSql, conn);
            OleDbDataAdapter adapter = new OleDbDataAdapter();
            adapter.SelectCommand = cmd;
            adapter.Fill(dataSetData, "Products");
            return dataSetData.Tables["Products"];
        }

    }
}