using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using System.Data.OleDb;
public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string ConStr = "Provider = Microsoft.ACE.OLEDB.12.0;Data source=" + Server.MapPath("mydata.accdb");
        OleDbConnection oc = new OleDbConnection(ConStr);
        try
        {
            //打开数据库连接
            oc.Open();
            OleDbDataAdapter oa = new OleDbDataAdapter("select * from mytable", oc);
            DataSet ds = new DataSet();
            oa.Fill(ds, "mytable");
            GridView1.DataSource = ds;
            GridView1.DataBind();
        }
        catch
        {
        }
        finally
        {
            //关闭数据库连接
            oc.Close();
        }

    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
       
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        GridView1.DataBind();
    }
}
