似乎是一个简单的语法错误但需要帮助。
protected void editback_Click(object sender, EventArgs e)
{
String EditStoryID = DropDownList3.SelectedItem.Value;
String EditProjectID = DropDownList1.SelectedItem.Value;
String EditRequirement = TextBoxBacklog.Text;
String EditLock = "0";
String connectionString = WebConfigurationManager.ConnectionStrings["ScrumString"].ConnectionString;
SqlConnection myConnection = new SqlConnection(connectionString);
myConnection.Open();
String query = "UPDATE product_backlog SET (project_id=@project_id,user_story=@user_story,is_locked=@is_locked) WHERE project_backlog.id = (@id)";
SqlCommand commandEdit = new SqlCommand(query, myConnection);
commandEdit.Parameters.AddWithValue("@project_id", EditProjectID);
commandEdit.Parameters.AddWithValue("@id", EditStoryID);
commandEdit.Parameters.AddWithValue("@user_story", EditRequirement);
commandEdit.Parameters.AddWithValue("@is_locked", EditLock);
commandEdit.ExecuteNonQuery();
Page.Response.Redirect(Page.Request.Url.ToString(), true);
Labelsuccess.Text = "User story has been updated";
TextBoxBacklog.Text = "";
}
答案 0 :(得分:1)
set
子句不应该用括号括起来:
UPDATE product_backlog
SET project_id = @project_id,
user_story = @user_story,
is_locked = @is_locked
WHERE project_backlog.id = (@id);
答案 1 :(得分:0)
您必须在SET语句后删除括号。 它们在WHERE语句之后除外,但SET必须没有,即使您要更新多个字段
UPDATE your_table SET key=@value WHERE id = (@id)