Results 1 to 3 of 3

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

  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.

  2. #2

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

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

    The ticks were the prob

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

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

    The apostrophes you mean? Yes, since parameterized values get that added automatically when you specify the type.

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