Issues w/ using a DataTable with a TableAdapter's Update method

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Craig Buchanan

    #1

    Issues w/ using a DataTable with a TableAdapter's Update method

    I created a TableAdapter (TA) in my VB 2005 project. I tested it to ensure
    that its CRUD functionality is what I expected it to be.

    I'm using the TA and its strongly-typed DataTable (DT) in my Wizard.
    Initially, I populate the DT using the TA.GetData.

    I pass the DT to a ASCX-styled control that 'pivots' (turns years into
    columns) the data into a new DataTable (DT2), then binds it (DT2) to a
    GridView form. I save the original DT in the viewstate. So far so good.

    When I want to save the data, I compare the values in GridView to the DT
    that has been retrieve from the viewstate. The DT's rows are modified
    accordingly. So far so good.

    However, when I attempt to use the TA's Update method, passing the DT, I get
    an error about a missing parameter. I'm assuming that the parameter's value
    is supplied by the field that has a matching name. I've noticed that each
    row has a value in this field.

    What am I missing here?

    Another oddity, perhaps. If don't make an changes in the pivot grid, there
    won't be any changes to the DT. Why is it that the each row's rowstate is
    'modified'? Could this be related my the Update issue?

    Thanks in advance.

    Craig Buchanan


  • Craig Buchanan

    #2
    Re: Issues w/ using a DataTable with a TableAdapter's Update method

    Solved my own problem.

    The first issue related to the parameter collection for the InsertCommand
    and UpdateCommand. While the ParameterName was correct, the SourceColumn's
    value didn't match the value in the DataTable. One needs to review the
    parameter collection more closely after changing the command's CommandText.
    Once the parameters were corrected, the TableAdapter's Update command worked
    correctly.

    The second issue related to how I was assigning values to each row in the
    DT. I changed the logic to only change the field's value if the new value
    (supplied by a TextBox) differed. As a result, the rowstates reflected what
    I would expect.

    Hope this helps someone.

    "Craig Buchanan" <someone@micros oft.comwrote in message
    news:%23DPD2mE6 IHA.3696@TK2MSF TNGP04.phx.gbl. ..
    >I created a TableAdapter (TA) in my VB 2005 project. I tested it to ensure
    >that its CRUD functionality is what I expected it to be.
    >
    I'm using the TA and its strongly-typed DataTable (DT) in my Wizard.
    Initially, I populate the DT using the TA.GetData.
    >
    I pass the DT to a ASCX-styled control that 'pivots' (turns years into
    columns) the data into a new DataTable (DT2), then binds it (DT2) to a
    GridView form. I save the original DT in the viewstate. So far so good.
    >
    When I want to save the data, I compare the values in GridView to the DT
    that has been retrieve from the viewstate. The DT's rows are modified
    accordingly. So far so good.
    >
    However, when I attempt to use the TA's Update method, passing the DT, I
    get an error about a missing parameter. I'm assuming that the parameter's
    value is supplied by the field that has a matching name. I've noticed
    that each row has a value in this field.
    >
    What am I missing here?
    >
    Another oddity, perhaps. If don't make an changes in the pivot grid,
    there won't be any changes to the DT. Why is it that the each row's
    rowstate is 'modified'? Could this be related my the Update issue?
    >
    Thanks in advance.
    >
    Craig Buchanan
    >

    Comment

    Working...