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)
{
yuanshi();
//yuanshi2();
}
private void yuanshi2()
{
OleDbConnection conn = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=|datadirectory|db.mdb;");
OleDbCommand comm = new OleDbCommand("select * from s", conn);
conn.Open();
OleDbDataReader dr = comm.ExecuteReader(CommandBehavior.CloseConnection);
DataTable dt = new DataTable();
dt.Load(dr);
this.GridView1.DataSource = dt;
this.GridView1.DataBind();
}
private void yuanshi()
{
OleDbConnection conn = new OleDbConnection("provider=microsoft.jet.oledb.4.0;Data source=|datadirectory|db.mdb;");
OleDbCommand comm = new OleDbCommand("select * from s", conn);
OleDbDataAdapter database = new OleDbDataAdapter(comm);
DataSet ds = new DataSet();
conn.Open();
database.Fill(ds, "s");
this.GridView1.DataSource = ds.Tables[0].DefaultView;
this.GridView1.DataBind();
conn.Close();
}
}