Results 1 to 3 of 3

Thread: [RESOLVED] Trying to update a value in the database. Asp.Net/C#/SQL/VS2005

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member gjon's Avatar
    Join Date
    Nov 2004
    Location
    Inescapable Void
    Posts
    442

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

    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();
    }
    Last edited by gjon; Oct 4th, 2007 at 08:27 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width