关于asp.net一个数据更新胡问题!在线等!!
public SqlConnection cn = new SqlConnection(ConfigurationManager.AppSettings[ "connstr "]);
protected void Page_Load(object sender, EventArgs e)
{
string sqlshow = "select * from news ";
cn.Open();
SqlCommand cm = new SqlCommand(sqlshow,cn);
SqlDataReader dr = cm.ExecuteReader();
if (dr.Read())
{
this.news_txt.Text = dr[ "news "].ToString();
}
dr.Close();
cn.Close();
}
public bool updatenews(string news)
{
string sqlupdate = "update news set news = ' " +news+ " ' ";
cn.Open();
SqlCommand cm = new SqlCommand(sqlupdate,cn);
SqlDataReader dr = cm.ExecuteReader();
if (dr.Read())
{
return true;
}
else
{
return false;
}
}
protected void edit_btn_Click1(object sender, EventArgs e)
{
string news;
news = this.news_txt.Text.ToString();
if (updatenews(news))
{
Response.Redirect( "main.aspx ");
}
}
以上是我做的一个小型新闻发布系统的新闻信息修改界面代码,可是在运行时修改的信息总是不能成功!
有大侠帮我看看!
谢谢!
------解决方案--------------------string id = "你要修改的数