using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.OleDb; public partial class userShow : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { this.Label1.Text = System.DateTime.Now.ToString(); loadData(); } protected void Button2_Click(object sender, EventArgs e) { OleDbConnection conn; OleDbCommand cmd; string olecmd, oleString,value; value = this.TextBox1.Text; Session.Add("key", value); oleString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("news.mdb"); olecmd = "select * from userLoad where userName='"; olecmd += TextBox1 .Text.Trim(); olecmd += "'and userPassword='"; olecmd += TextBox2 .Text.Trim() + "'"; conn = new OleDbConnection();//实例化对象 conn.ConnectionString = oleString; cmd = new OleDbCommand(); cmd.Connection = conn; cmd.CommandText = olecmd; conn.Open(); OleDbDataReader dr = cmd.ExecuteReader(); if (this.TextBox1.Text.Trim() == "" || this.TextBox2.Text.Trim() == "") { Response.Redirect("usersub.aspx"); } if (dr.Read()) { Session["username"] = this.TextBox1.Text; Response.Redirect("todayNews.aspx"); } else { this.TextBox1 .Focus(); this.TextBox1 .Text = ""; this.TextBox2 .Text = ""; } conn.Close(); dr.Close(); } protected void Button3_Click(object sender, EventArgs e) { this.TextBox1.Focus(); this.TextBox1.Text = ""; this.TextBox2.Text = ""; } DataSet GetDataSet() { OleDbConnection conn; OleDbCommand cmd; conn = new OleDbConnection(); conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("news.mdb"); conn.Open(); cmd = new OleDbCommand(); cmd.CommandText = "select * from newsData where newsclassid=0"; cmd.Connection = conn; OleDbDataAdapter oleDA = new OleDbDataAdapter(); oleDA.SelectCommand = cmd; DataSet ds = new DataSet(); oleDA.Fill(ds, "newsData"); conn.Close(); return ds; } void loadData() { DataSet ds = GetDataSet(); GridView1.DataSource = ds; GridView1.DataBind(); } protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { Response.Redirect("userLogin.aspx"); } protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; loadData(); } }
- 1
- 2
- 粉丝: 1
- 资源: 6
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助