access链接最原始代码,两种
Posted 侯伟东
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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();
}
}
以上是关于access链接最原始代码,两种的主要内容,如果未能解决你的问题,请参考以下文章
在离子中,Access-Control-Allow-Origin不允许使用原始http:// localhost:8100