error while updating a database in ASP.NET

Posted by Viredae on Stack Overflow See other posts from Stack Overflow or by Viredae
Published on 2010-06-14T06:35:01Z Indexed on 2010/06/14 7:12 UTC
Read the original article Hit count: 238

Filed under:
|

I am having trouble updating an SQL database, the problem is not that it doesn't update at all, but that particular parameters are being updated while the others are not.

here is the code for updating the parameters:

string EditRequest = "UPDATE Requests SET Description = @Desc, BJustif = @Justif, Priority = @Priority, Requested_System = @Requested, Request_Status = @Stat WHERE";
    EditRequest += " Req_ID=@ID";

    SqlConnection Submit_conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DBConn"].ConnectionString);
    SqlCommand Submit_comm = new SqlCommand(EditRequest, Submit_conn);


    Submit_comm.Parameters.AddWithValue("@ID", Request.QueryString["reqid"]);
    Submit_comm.Parameters.AddWithValue("@Desc", DescBox.Text);
    Submit_comm.Parameters.AddWithValue("@Justif", JustifBox.Text);
    Submit_comm.Parameters.AddWithValue("@Priority", PriorityList.SelectedValue);
    Submit_comm.Parameters.AddWithValue("@Requested", RelatedBox.Text);
    Submit_comm.Parameters.AddWithValue("@Stat", 1);

    Submit_conn.Open();

    Submit_comm.ExecuteNonQuery();

    Submit_comm.Dispose();

    Submit_comm = null;

    Submit_conn.Close();

    get_Description();

    Page.ClientScript.RegisterStartupScript(this.GetType(), "Refresh", "ReloadPage();", true);

this function is called by a button on a pop-up form which shows the parameters content that is being changed in a text box which is also used to submit the changes back to the database, but when I press submit, the parameters which are displayed on the form don't change, I can't find any problem wit the code, even though I've compared it to similar code which is working fine.

In case you need to, here is one of the text boxes I'm using to display and edit the content:

<asp:TextBox ID="JustifBox" TextMode="MultiLine" runat="server" Width="250" Height="50"></asp:TextBox>

What exactly is wrong with the code?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET