xiu2.cs
资源名称:Visual.rar [点击查看]
上传用户:yiyuerguo
上传日期:2014-09-27
资源大小:3781k
文件大小:2k
源码类别:
C#编程
开发平台:
Others
- using System;
- using System.Data;
- using System.Data.OleDb;
- using System.IO;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.HtmlControls;
- namespace www
- {
- public class MyCodeBehind : Page
- {
- public System.Web.UI.WebControls.TextBox biaoti;
- public System.Web.UI.WebControls.TextBox neirong;
- public System.Web.UI.WebControls.TextBox zuozhe;
- public HtmlInputButton Button1;
- public DataRow dr;
- public String newsid;
- void Page_Load(Object sender, EventArgs e)
- {
- if(!IsPostBack)
- {
- newsid = Request.Params["id"];
- OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+ Server.MapPath("candsql.mdb"));
- OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM aa WHERE id="+newsid, myConnection);
- DataSet ds = new DataSet();
- myCommand.Fill(ds, "aa");
- dr = ds.Tables["aa"].Rows[0];
- biaoti.Text=dr["biaoti"].ToString();
- neirong.Text=dr["neirong"].ToString();
- zuozhe.Text=dr["zuozhe"].ToString();
- }
- }
- public void Button1_Click(object Source, EventArgs e)
- {
- newsid = Request.Params["id"];
- OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+ Server.MapPath("candsql.mdb"));
- OleDbCommand myCommand = new OleDbCommand("UPDATE aa set biaoti='" + biaoti.Text + "', neirong='" + neirong.Text + "',zuozhe='" + zuozhe.Text +"' WHERE id="+newsid, myConnection);
- myCommand.Connection.Open();
- myCommand.ExecuteNonQuery();
- myCommand.Connection.Close();
- Response.Redirect("update3.aspx") ;
- }
- }
- }