谁帮我看看代码
- C# code
protected void modify_Click(object sender, EventArgs e) { int id = Convert.ToInt32(Request.QueryString["id"]); string title = this.newsTitle.Text; string content = this.newsContent.Value; string sql = string.Format(@"updata news set n_title = '{0}',n_title = '{1}' where n_id = {2}", title,content,id); int num = db.NotQuery(sql); if (num > 0) { Response.Redirect("NewsManage.aspx"); } }
DBHelp类
- C# code
//执行不是查询的语句 public int NotQuery(string s) { int num = 0; try { myConnection.Open(); //string sql = string.Format(s); OleDbCommand myCommand = new OleDbCommand(s, myConnection); num = myCommand.ExecuteNonQuery(); return num; } catch (Exception e) { e.ToString(); } finally { myConnection.Close(); } return num; }
------解决方案--------------------------------------------------------
updata >> update
"update news set n_title = '"+ title +"',n_title = '"+ content +"' where n_id = '"+ id+"'"
try above sql statement.
------解决方案--------------------------------------------------------
你肯定这个update语句写错了
告诉你一个方法,就是现在数据库里写好,然后再把那些传的参数换上去。。。这样错误就小了
------解决方案--------------------------------------------------------
updata写错了
------解决方案--------------------------------------------------------
更新语句updata写错了!
------解决方案--------------------------------------------------------
string sql = string.Format(@"updata news set n_title = '{0}',n_title = '{1}' where n_id = {2}", title,content,id);
sql语句错了,
1、updata 写错了 改成update
2、里面有两个字段一样n_title,估计是n_content