title: C# set database to specific data that I want
body: <p>I am currently trying delete my advertisement. But instead of deleting it from database I just want to set the status from <code>1</code> ( which means active ) to <code>0</code> (which means inactive). I have tried to use query <code>UPDATE</code>. But I do not know the format. My current code is</p>
  
  <pre><code>protected void btnDelete_Click(object sender, EventArgs e)
      {
          if (sqlCon.State == ConnectionState.Closed)
              sqlCon.Open();
          SqlCommand sqlCmd = new SqlCommand("DeleteImage", sqlCon);
          sqlCmd.CommandType = CommandType.StoredProcedure;
          sqlCmd.Parameters.AddWithValue("AdvID", Convert.ToInt32(hfContactID.Value));
          sqlCmd.ExecuteNonQuery();
          sqlCon.Close();
          Clear();
          FillGridView();
          LitMsg.Text = "Deleted Successfully";
          ButSave.Enabled = true;
          Image1.Visible = false;
      }
  </code></pre>
  
  <p>and I believe that <code>Delete</code> query does not change my status to <code>0</code> so my update query is something like this.</p>
  
  <pre><code>protected void btnUpdate_Click(object sender, EventArgs e)
      {
          if (FileImgsave.HasFile == true)
          {
  
  
              string imgfile = Path.GetFileName(FileImgsave.PostedFile.FileName);
              //FileImgsave.SaveAs("Images/" + imgfile);
              FileImgsave.SaveAs(Server.MapPath("~/Images/" + imgfile));
              sqlCon.Open();
              SqlCommand cmd = sqlCon.CreateCommand();
              cmd.CommandType = CommandType.Text;
              cmd.CommandText = "UPDATE Advertisement SET Item=@item,ImgPath=@image,Name=@name Where AdvID='" + AdsTb.Text + "'";
              cmd.Parameters.AddWithValue("@name", nameTb.Text);
              cmd.Parameters.AddWithValue("@item", imgfile);
              cmd.Parameters.AddWithValue("@image", "~/Images/" + imgfile);
              cmd.ExecuteNonQuery();
              sqlCon.Close();
              FillGridView();
              LitMsg.Text = "Update successfully!";
              Clear();
          }
  </code></pre>
  
  <p>Below is my delete query </p>
  
  <pre><code>ALTER PROC [dbo].[DeleteImage]
  @AdvID int
  
  AS
      BEGIN
      DELETE FROM Advertisement
      WHERE AdvID = @AdvID
      END
  </code></pre>