今天终于发薪了.苦等了十几天啊.顺便请教问题(ASP.NET)
今天终于发薪了.苦等了两周啊.还当不发了呢.再不发打算明天不来上班了.结果发了,哈哈.
我原来学ASP的,现在在学.NET
刚学.现在遇到一个问题,请各位高手指教.
public partial class edit : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int id = Convert.ToInt32(Request.QueryString["id"]);
idid.Text = Request.QueryString["id"];
BindTopicData(id);
}
private void BindTopicData(int id)
{ ///获取数据
OleDbConnection con = new OleDbConnection(getconn());
con.Open();
OleDbCommand cmd = new OleDbCommand("select * from ZD_Article where id=" + id, con);
OleDbDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
if (dr.Read())
{
titles.Text = dr["title"].ToString();
writter.Text = dr["writter"].ToString();
Content.Text = dr["Content"].ToString();
con.Close();
}
}
protected string getconn()
{
string connstring;
connstring = ConfigurationManager.ConnectionStrings["dataConnectionString"].ConnectionString;
return connstring;
}
protected void Button1_Click(object sender, EventArgs e)
{
string titless;
titless= titles.Text;
string Contentss ;
Contentss = Content.Text;
Contentss = Server.HtmlEncode(Contentss.Replace("'", "!"));
string writters;
writters= writter.Text;
int idd = Convert.ToInt32(idid.Text);
OleDbConnection con = new OleDbConnection(getconn());
string query;
query = "update ZD_Article set title='" + titless + "',writter='" + writters + "',Content='" + Contentss + "' where id=" + idd;
con.Open();
OleDbCommand cmd = new OleDbCommand(query, con);
if (cmd.ExecuteNonQuery()>0);
{
Response.Write("<script>alert('更新成功!');</script>");
Response.Redirect("Default.aspx");
}
con.Close();
}
}
问题是,我点更新的时候.titles.text,Content.text,writter.text 中的内容不变.
老是修改不了内容,不知道为什么,请高手指点.先谢过了.