Updatinging a Table with Primary Keys through Visual Web Developer

  • Is it possible to update a Table with Primary keys? For Example:

    Table with Following columns

    pk_Column1

    pk_Column2

    pk_Column3

    Column4

    Column5

    I've written the following query on the underlying Data Table which appears as the Dataset.xsd file:

    UPDATE [Table]

    SET

    pk_Column1 = @pk_Column1,

    pk_Column2 = @pk_Column2,

    pk_Column3 = @pk_Column3,

    Column4 = @Column4,

    Column5 = @Column5,

    WHERE (pk_Column1 = @Original_pk_Column1) AND

    (pk_Column2 = @Original_pk_Column2) AND

    (pk_Column3 = @Original_pk_Column3)

    The above SQL is a Dataset on a TableAdapter which is attached to an

    Object on an ASP page. The Update Method is:

    Update(String pk_Column1, String pk_Column2, String pk_Column3, String Column4, String Column5), returns Int32

    I attached a Gridview object to the above Object. The site works fine, and Columns 4 and 5 can be updated normally. However, I can't get the Primary Key columns to render updating. I can only update the non-primary key data. But I need to have the ability to update the Primary key data. (I am able to update the primary key data in the underlying table)

    In the Properties area for the object I have the following:

    OldValuesParameterFormatString set to original_{0}

    I was instructed on another web site that this enables Primary key data to be Updated (edited)

    Under Properities on the Gridview object, I have the primary keys Col 1, 2, 3 set up as DataKeyNames

    Any Advice? This is driving me crazy. I:crazy:

  • Are there any constraint on the table definition (i.e. identity fields, auto increment...)

    Usually if the data you are inserting does not duplicate the key, the udate will success...

    See The Jenga blog

  • Hi,

    there's nothing in the table definition I can see that has those settings.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply