[我的ASP.net学习历程]DataAdapter操作之(二)
来源:互联网 发布:origin绘图软件2017 编辑:程序博客网 时间:2024/05/01 02:50
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
string dbPath = @"Data/dbTest.mdb";
string db = Server.MapPath (dbPath);
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + db;
string strSQL = "SELECT [CustomerID],[Address] FROM Customers";
DataSet ds = new DataSet();
OleDbConnection conn = new OleDbConnection(connectionString);
OleDbCommand cmd = new OleDbCommand(strSQL,conn);
OleDbDataAdapter da = new OleDbDataAdapter();
//通过Command链接数据库操作
da.SelectCommand = cmd;
da.Fill(ds,"testMdb");
DataGrid1.DataSource = ds.Tables["testMdb"].DefaultView;
DataGrid1.DataBind();
}
private void Page_Load(object sender, System.EventArgs e)
{
string dbPath = @"Data/dbTest.mdb";
string db = Server.MapPath (dbPath);
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + db;
string strSQL = "SELECT [CustomerID],[Address] FROM Customers";
DataSet ds = new DataSet();
OleDbConnection conn = new OleDbConnection(connectionString);
OleDbCommand cmd = new OleDbCommand(strSQL,conn);
OleDbDataAdapter da = new OleDbDataAdapter();
//通过Command链接数据库操作
da.SelectCommand = cmd;
da.Fill(ds,"testMdb");
DataGrid1.DataSource = ds.Tables["testMdb"].DefaultView;
DataGrid1.DataBind();
}
- [我的ASP.net学习历程]DataAdapter操作之(二)
- [我的ASP.net学习历程]DataAdapter操作之(一)
- [我的ASP.net学习历程]数据库操作之(二)
- [我的ASP.net学习历程]数据库操作(一)
- [ASP.NET学习笔记之二]数据集和数据库的同步-DataAdapter的使用
- [我的ASP.net学习历程]DropDownList
- [我的ASP.net学习历程]IsPostBack
- [我的ASP.net学习历程]out
- [我的ASP.net学习历程]Reference
- [我的ASP.net学习历程]RegularExpressionValidator
- [我的ASP.net学习历程]TextBox和Label的数据梆定(二)
- [我的ASP.net学习历程]ArrayList用法
- [我的ASP.net学习历程]Cache和DateTime
- [我的ASP.net学习历程]DataGrid(DataBind)(1)
- [我的ASP.net学习历程]DataGrid(DataBind)(2)
- [我的ASP.net学习历程]DataGrid(PageChange)(1)
- [我的ASP.net学习历程]DataGrid(PageChange)(2)
- [我的ASP.net学习历程]DataList(DataBind)(1)
- 世界上最美丽的路...
- ComboBox的DataValue值
- 如何 动态编译自己写的代码
- 如何使用 Quota
- [我的ASP.net学习历程]DataAdapter操作之(一)
- [我的ASP.net学习历程]DataAdapter操作之(二)
- Blog日渐普及 成为带宽“黑洞”?
- 快速配置weblogic8.X的应用目录
- [我的ASP.net学习历程]DataBase Settion(3)
- 使用 Microsoft SQL Server 2000 各种版本或组件而必须安装的操作系统
- 关于asp.net中文文件名超长的下载问题
- [我的ASP.net学习历程]DataBase Settion(4)
- [我的ASP.net学习历程]DataBase Settion(5)
- [我的ASP.net学习历程]DataBase Settion(6)