Asp.Net学习笔记:使用DataSet
2007-04-04 14:12
501 查看
Asp.Net学习笔记:使用DataSet |
来源:从互联网收集整理并转载 |
<% @ Page Language="C#" Debug="True"%> <% @ Import Namespace="System.Data" %> <% @ Import Namespace="System.Data.OleDb" %> <s cript language="C#" runat="server"> public void Page_Load(Object src,EventArgs e) { //各种String 的设置 String MyConnString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+Server.MapPath("blog.mdb"); String StrSel1 = "select id,topic,username,addtime from blog"; String StrSel2 = "select USERid,UserName,UserEmail from [user]"; String StrSel3 = "select * from [subject]"; DataSet MyDataSet = new DataSet(); OleDbConnection MyConnection = new OleDbConnection(MyConnString); //open DataAdapter OleDbDataAdapter MyAdapter1 = new OleDbDataAdapter(StrSel1,MyConnection); OleDbDataAdapter MyAdapter2 = new OleDbDataAdapter(StrSel2,MyConnection); OleDbDataAdapter MyAdapter3 = new OleDbDataAdapter(StrSel3,MyConnection); //将各表数据存入DataSet MyAdapter1.Fill(MyDataSet,"blog"); MyAdapter2.Fill(MyDataSet,"user"); MyAdapter3.Fill(MyDataSet,"subject"); //交给DataGrid显示 DataGrid1.DataSource = MyDataSet.Tables["blog"].DefaultView; DataGrid2.DataSource = MyDataSet.Tables["user"].DefaultView; DataGrid3.DataSource = MyDataSet.Tables["subject"].DefaultView; DataGrid1.DataBind(); DataGrid2.DataBind(); DataGrid3.DataBind(); } </s cript> <html> <head><title>DataSet的使用</title></head> <body> <form runat="server"> <ASP:DataGrid id="DataGrid1" runat="server" AllowPaging="True" PageSize="5" PagerStyle-Mode="NumericPages" BorderColor="black" BorderWidth="1" GridLines="Both" Cellpadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd" AlternatingItemStyle-BackColor="#eeeeee" /> <hr /> <ASP:DataGrid id="DataGrid2" runat="server" AllowPaging="True" PageSize="4" PagerStyle-Mode="NumericPages" BorderColor="black" BorderWidth="1" GridLines="Both" Cellpadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd" AlternatingItemStyle-BackColor="#eeeeee" /> <hr /> <ASP:DataGrid id="DataGrid3" runat="server" AllowPaging="True" PageSize="5" PagerStyle-Mode="NumericPages" BorderColor="black" BorderWidth="1" GridLines="Both" Cellpadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd" AlternatingItemStyle-BackColor="#eeeeee" /> </form><p /> </body> </html> |
相关文章推荐
- 使用Visual Studio Code开发Asp.Net Core WebApi学习笔记(六)-- 依赖注入
- ASP.NET 学习笔记_01 广告控件的使用
- ASP.NET 3.5核心编程学习笔记(37):缓存的使用
- asp .net学习笔记之使用jmail发送邮件
- <转>ASP.NET学习笔记之在ASP.NET MVC中使用DropDownList
- 【原创】Asp.Net MVC学习笔记之-使用AcceptVerbs标签来制定Action的响应行为
- 学习笔记--asp.net主题和外观(转自msdn,仅为自己学习存储和有意读者使用)
- Asp.net Ajax 学习笔记2 UpdatePanel的使用(上)
- ASP.NET学习笔记[1] - iis不能使用的问题解决
- [ASP.NET学习笔记之二十]ASP_NET 2.0 中web part使用指南
- Asp.net学习笔记----使用GridView+ObjectDataSource进行自定义分页排序
- [ASP.NET学习笔记之二]数据集和数据库的同步-DataAdapter的使用
- Asp.Net Ajax 学习笔记3 UpdatePanel的使用(上)
- CUBRID学习笔记 39 net使用dataset 返回查询的数据
- Sharepoint学习笔记—Debug&TroubleShooting--Developer Dashboard的使用(4.显示ASP.NET Tracing信息)
- 学习笔记:asp.net中使用跟踪(trace)
- Asp.net Ajax 学习笔记4 UpdatePanel的使用(上)
- 学习笔记--asp.net母版页(转自msdn,仅为自己学习存储和有意读者使用)
- Asp.net core 2.0.1 Razor 的使用学习笔记(五)
- [ASP.NET学习笔记之十七]ASP.NET DataGrid 高级使用技巧