我现在需要更新数据库内容,但是总是更新不了,请大家帮我看看!谢谢!
private void newsok_Click(object sender, System.EventArgs e)
{
string class11=DropDownListclass1.SelectedItem.Value;
string class22=Dropdownlistclass2.SelectedItem.Value;
string class33=Dropdownlistclass3.SelectedItem.Value;
string jqtitle1=Request.Form["jqtitle"].Trim();
string jqnews1=FCKeditor1.Value;
string jqauthor1=Request.Form["jqauthor"];
string strUpdate="UPDATE jq_news SET jqtitle='"+jqtitle1+"',jqnews='"+jqnews1+"',jqauthor='"+jqauthor1+"',class1='"+class11+"',class2='"+class22+"',class3='"+class33+"' where id="+b+"";
try
{
SqlConnection MyConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand MyCommand = new SqlCommand(strUpdate,MyConnection);
MyConnection.Open();
MyCommand.ExecuteNonQuery();
Info.Text="数据已经修改!";
jqtitle.Text="";
jqauthor.Text="";
FCKeditor1.Value="";
MyConnection.Close();
Response.Redirect("managenews.aspx");
}
catch(Exception ee)
{
Info.Text="发生错误:"+ee.Message;
}
}
我哪里写的不对吗?
private void newsok_Click(object sender, System.EventArgs e)
{
string class11=DropDownListclass1.SelectedItem.Value;
string class22=Dropdownlistclass2.SelectedItem.Value;
string class33=Dropdownlistclass3.SelectedItem.Value;
string jqtitle1=Request.Form["jqtitle"].Trim();
string jqnews1=FCKeditor1.Value;
string jqauthor1=Request.Form["jqauthor"];
string strUpdate="UPDATE jq_news SET jqtitle='"+jqtitle1+"',jqnews='"+jqnews1+"',jqauthor='"+jqauthor1+"',class1='"+class11+"',class2='"+class22+"',class3='"+class33+"' where id="+b+"";
try
{
SqlConnection MyConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand MyCommand = new SqlCommand(strUpdate,MyConnection);
MyConnection.Open();
MyCommand.ExecuteNonQuery();
Info.Text="数据已经修改!";
jqtitle.Text="";
jqauthor.Text="";
FCKeditor1.Value="";
MyConnection.Close();
Response.Redirect("managenews.aspx");
}
catch(Exception ee)
{
Info.Text="发生错误:"+ee.Message;
}
}
我哪里写的不对吗?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货