首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

各位帮小弟我看看为什么SQL更新不成功啊

2012-06-11 
各位帮我看看为什么SQL更新不成功啊??protected void Button1_Click(object sender, EventArgs e){string

各位帮我看看为什么SQL更新不成功啊??
protected void Button1_Click(object sender, EventArgs e)
  {
  string sqltr = "Server=.;User ID=sa;Pwd=123;DataBase=student";
  string category = DropDownList1.SelectedValue;
  string admin = DropDownList2.SelectedValue;
  string group = DropDownList3.SelectedValue;
  string priority = DropDownList4.SelectedValue;
  string summary = TextBox2.Text;
  string description = TextBox3.Text;
  string status = DropDownList5.SelectedValue;
  string b = TextBox4.Text.ToString();
  SqlConnection connection = new SqlConnection(sqltr);
  SqlCommand command;
  string sql = string.Format("update bug set category='{0}',admin='{1}',[group]='{2}',priority='{3}',summary='{4}',description='{5}',status='{6}'where ID='{7}'", category, admin, group, priority, summary, description, status, b);
  connection.Open();
  command = new SqlCommand(sql, connection);
  int count = command.ExecuteNonQuery();
  if (count > 0)
  {
  ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>alert('修改成功!')</script>");
  }
  else
  {
  ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>alert('添加成功!')</script>");
  }
  connection.Close();
  }

[解决办法]
如无提示,那就考虑SQL的参数是否正确
[解决办法]
查看一下connection里的UpdateCommand对象是否被创建了

热点排行