xiu.aspx.cs
来自「简单入门新闻发布系统源码 具有新闻的添加、管理及显示等基本功能(可以进行图片上」· CS 代码 · 共 52 行
CS
52 行
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;
//该源码下载自www.51aspx.com(51aspx.com)
public partial class xiu : System.Web.UI.Page
{
public DataRow dr;
public String newsid;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
newsid = Request.Params["id"];
// Response.Write("newsid==="+newsid);
string strConnnection = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";
strConnnection += Server.MapPath(".\\App_Data\\news.mdb");
OleDbConnection myconn = new OleDbConnection(strConnnection);
OleDbDataAdapter odr = new OleDbDataAdapter("select * from contents where id="+newsid,myconn);
DataSet ds = new DataSet();
odr.Fill(ds,"contents");
dr = ds.Tables["contents"].Rows[0];
txtBiaoti.Text = dr["biaoti"].ToString();
txtNeirong.Text = dr["neirong"].ToString();
txtZuozhe.Text = dr["zuozhe"].ToString();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
newsid = Request.Params["id"];
string strConnnection = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";
strConnnection += Server.MapPath(".\\App_Data\\news.mdb");
OleDbConnection myconn = new OleDbConnection(strConnnection);
myconn.Open();
OleDbCommand updatecmd = new OleDbCommand("update contents set biaoti='"+txtBiaoti.Text+"',neirong='"+txtNeirong.Text+"',zuozhe='"+txtZuozhe.Text+"' where id="+newsid,myconn);
updatecmd.ExecuteNonQuery();
myconn.Close();
Response.Redirect("delnews.aspx");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?