nspace.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 nspace
- {
- public class MyCodeBehind : Page
- {
- public DataGrid MyList;
- public DataGrid MyListb;
- private void Page_Load(Object sender, EventArgs e)
- {
- if(!IsPostBack)
- {
- OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+ Server.MapPath("candsql.mdb"));
- OleDbDataAdapter myCommand = new OleDbDataAdapter("select 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 myCommandb = new OleDbDataAdapter("select bb.* FROM bb ", myConnection);
- DataSet ds = new DataSet();
- DataSet dsb = new DataSet();
- myCommand.Fill(ds, "aa");
- myCommandb.Fill(dsb, "bb");
- MyList.DataSource = ds.Tables["aa"].DefaultView;
- MyListb.DataSource = dsb.Tables["bb"].DefaultView;
- MyList.DataBind();
- MyListb.DataBind();
- }
- }
- protected string FormatString(string str)
- {
- str=str.Replace(" "," ");
- str=str.Replace("<","<");
- str=str.Replace(">",">");
- str=str.Replace('n'.ToString(),"<br>");
- return str;
- }
- }
- }