www.cs
资源名称:Visual.rar [点击查看]
上传用户:yiyuerguo
上传日期:2014-09-27
资源大小:3781k
文件大小:1k
源码类别:
C#编程
开发平台:
Others
- using System;
- using System.Data;
- using System.Data.OleDb;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.HtmlControls;
- namespace www
- {
- public class MyCodeBehind : Page
- {
- public DataGrid MyList;
- public DataGrid MyList1;
- private void Page_Load(Object sender, EventArgs e)
- {
- if(!IsPostBack)
- {
- OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+ Server.MapPath("new.mdb"));
- OleDbDataAdapter myCommand = new OleDbDataAdapter("select top 8 aa.* FROM aa WHERE typeid=1 order by shijian desc", myConnection);
- //OleDbDataAdapter myCommand = new OleDbDataAdapter("select top 7 aa.* FROM aa WHERE typeid=1 order by shijian desc", myConnection);
- // OleDbDataAdapter myCommand1 = new OleDbDataAdapter("select top 12 aa.* FROM aa WHERE typeid=2 order by shijian desc", myConnection);
- DataSet ds = new DataSet();
- myCommand.Fill(ds, "aa");
- // myCommand1.Fill(ds, "bb");
- MyList.DataSource = ds.Tables["aa"].DefaultView;
- // MyList1.DataSource = ds.Tables["bb"].DefaultView;
- MyList.DataBind();
- // MyList1.DataBind();
- }
- }
- protected string FormatString(string str)
- {
- str=str.Replace(" "," ");
- str=str.Replace("<","<");
- str=str.Replace(">",">");
- str=str.Replace('n'.ToString(),"<br>");
- return str;
- }
- }
- }