none
Dataview and dataview.table ? RRS feed

  • Question

  • Good morning,

    I have a dataview object that I fill with rows from a Database.

    Say I get back 10 rows.

    I then get a second list of records from another database.

    Say I get back 2 rows.

    I loop this 2nd set and add the rows into the first sets dataview object.

    So now the dataview object has 12 rows.

    Heres my issue, the dataviews, dataview.table, object only shows 11 rows.

    It never seems to see the last record.

    If I do a dv.AddNew() and then dv.Delete(DV.count - 1) just after the loop ends I get to see the last row. So now the DV.table shows 12 rows not 11.

    So I am guessing that dv.AddNew() is doing some sort of commit/update to the table object.

    My question is how do I do that commit/update without doing to Addnew+Delete last that I am currenlty forced to do.

    Hope that all made sense.

    Thanks for any replies.

    Deasun.

    Code Example:

    Dim intIDX As Integer = 0
    While (intIDX < dvOrderList2.Count)
      dvOrderList.AddNew()
      With dvOrderList
        .Item(dvOrderList.Count - 1).Item("Section") = dvOrderList2.Item(intIDX).Item("Section")
        .Item(dvOrderList.Count - 1).Item("BillingGrp") = dvOrderList2.Item(intIDX).Item("BillingGrp")
        .Item(dvOrderList.Count - 1).Item("Account Type") = dvOrderList2.Item(intIDX).Item("Account Type")
        .Item(dvOrderList.Count - 1).Item("Count Is") = dvOrderList2.Item(intIDX).Item("Count Is")
      End With                       
      intIDX += 1
    End While

    dvOrderList.AddNew()
    dvOrderList.Delete(dvOrderList.Count - 1)

    Thursday, October 18, 2012 2:24 PM

Answers

  • Im not sure about this case of AddNew.. but in fact DataViewRow has a some sort of commit, its the EndEdit() method.

    Ill suggest you try something like:

    ....
    DataViewRow item = dvOrderList.AddNew();
    ....
    ....
    ....
    item.EndEdit();

    At least for the last inserted item, because .AddNew automatically "commit" last item but not the one just returned, that could be why the last is missing.


    -


    Thursday, October 18, 2012 6:17 PM

All replies

  • May be there is a filter mismatch.

    For example, RowFilter for dvOrderList is something like "Section = 'x'" and RowFilter for dvOrderList2 is like "Section = 'y'". Now, when you add a row from dvOrderList2 to dvOrderList, you will not see the row in dvOrderList because the row doesn't fit in dvOrderList.

    Only observation it actually shows one extra row which is also wrong (probably a bug).


    Please mark this post as answer if it solved your problem. Happy Programming!

    Thursday, October 18, 2012 3:39 PM
  • Im not sure about this case of AddNew.. but in fact DataViewRow has a some sort of commit, its the EndEdit() method.

    Ill suggest you try something like:

    ....
    DataViewRow item = dvOrderList.AddNew();
    ....
    ....
    ....
    item.EndEdit();

    At least for the last inserted item, because .AddNew automatically "commit" last item but not the one just returned, that could be why the last is missing.


    -


    Thursday, October 18, 2012 6:17 PM