• access链接最原始代码,两种


    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();

        }

    }

    天道酬勤,厚积薄发。 君子之行,静以修身,俭以养德。 非淡泊无以明志,非宁静无以致远。 如有恒,何须三更起,半夜眠;最怕莫,三天打鱼两天晒网,竹篮打水一场空。
  • 相关阅读:
    jquery使用
    网站重构?
    WEB应用从服务器主动推送Data到客户端有那些方式?
    异步加载和延迟加载?
    平时如何管理你的项目?
    对前端界面工程师这个职位是怎么样理解的?它的前景会怎么样?
    约定优于配置(convention over configuration)
    JavaEE的13种核心技术
    The Spring Framework ConfigurableListableBeanFactory.java
    mySQL的boolean类型为tinyint(1)
  • 原文地址:https://www.cnblogs.com/houweidong/p/5560992.html
Copyright © 2020-2023  润新知