2
Answers

Trying to update a value in the database. Asp.Net/C#/SQL/VS2005

foo foolios

foo foolios

17y
2.6k
1
I don't really know how to check why it's not working.
I have a try/catch that tells me in the catch that it didn't succeed but not sure how to really know what's going on with it.

Here's my update attempt:

SqlCommand comm = new SqlCommand("UPDATE inventoryTbl SET categoryID = '@category' WHERE id = '@ID'", conn);

comm.Parameters.Add("@category", System.Data.SqlDbType.SmallInt);
comm.Parameters["@category"].Value = txtbx_itemCategory.Text;

        try
        {
            // Execute the command
            comm.ExecuteNonQuery();
            // Reload page if the query executed successfully
            //Response.Redirect("addrelatives.aspx");
        }
        catch
        {
            // Display error message
            bttnApplyChanges.Text = "Error";
        }
        finally
        {
            // Close the connection
            conn.Close();
        }
Answers (2)