0

Seems a simple syntax error but need help.

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 = "";
}
1
  • 1
    in your query try removing ( and ) in the set and also around @id Commented Nov 5, 2015 at 22:55

2 Answers 2

1

The set clause should not be surrounded by parentheses:

UPDATE product_backlog
    SET project_id = @project_id,
        user_story = @user_story,
        is_locked = @is_locked
   WHERE project_backlog.id = (@id);
Sign up to request clarification or add additional context in comments.

Comments

0

You must remove the parentheses after the SET statement. They are excepted after the WHERE statement but the SET must be without, even if you have more than 1 field you want to update

UPDATE your_table SET key=@value WHERE id = (@id)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.