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

        }

    }

    天道酬勤,厚积薄发。 君子之行,静以修身,俭以养德。 非淡泊无以明志,非宁静无以致远。 如有恒,何须三更起,半夜眠;最怕莫,三天打鱼两天晒网,竹篮打水一场空。
  • 相关阅读:
    abp架构中加载公共css样式表和公共js的文件目录位置
    angular中[hidden]="expression"注意事项
    angular中使用canvas画布做验证码
    AngularJs页面跳转
    Angular学习笔记【如何正确使用第三方组件】
    【JavaScript权威指南】——逻辑与(&&)
    angular学习笔记【ng2-charts】插件添加
    OpenLayers v4.2.0 -----地图延迟加载;
    Sharepoint 图片库字段名称(Title)和对应的内部名称(InternalName)
    Sharepoint JSCOM 列表操作
  • 原文地址:https://www.cnblogs.com/houweidong/p/5560992.html
Copyright © 2020-2023  润新知