none
Odd update behavior RRS feed

  • Question

  • I have a single record form filled with an assortment of controls (textboxes, comboboxes, etc.). This form is called from a couple of other forms, which close when the second form is opened. There are some inputs that are put into the form controls when it is opened then I have the option to save/update the record, using the following:

    Me.Validate()

    Me.TblMBItemMasterBindingSource.EndEdit()

    Me.TableAdapterManager.UpdateAll(Me._ItemMaster_1_0DataSet)

    My problem is that the updates fail to occur.  There is no error posted either.

    Now there is another instance I use this same form and in that instance the data is updated when I click the save button.

    The only difference that I can find with this form is how the record is called to the form when it is opened.

    In the case where the update occurs the form is opened using the following:

    Me.TblMBItemMasterBindingSource.Position = glbintRowNum - 1

    When it update fails to occur the form is opened using the following query:

    Me.TblMBItemMasterTableAdapter.qryGetByItemNum(Me._ItemMaster_1_0DataSet.tblMBItemMaster)

    In both cases the form is opened to the appropriate record selected.

    It seems obvious to me that it has something to do with using a query to get to the selected record for display/modification, but I have no idea why that would be the case.  And there is a reason why I use the query in one instance but not the other and will be happy to explain if desired.


    gwboolean

    • Moved by Youjun Tang Thursday, September 24, 2015 9:57 AM ado.net dataset related
    Thursday, September 17, 2015 9:02 PM

All replies

  • Hi gwboolean,

    Based on your description, I could not reproduce your issue, if you could share a reproducible code sample here, it would be helpful.

    And here is the MSDN document about TableAdapterManager, you could refer to it for details.

    Best Regards,

    Xavier Eoro


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, September 21, 2015 7:49 AM
  • Hello,

    From what I have read, the update works when there is a record present which I assume from you setting the position of the BindingSource while the method that is not working you are populating data via a query for the TableAdapter.

    From the above all I can say is may be you need to move the BindingSource position to the record that has been loaded via qryGetByItemNumber.

    Lastly, looking at the code gives no pause to believe there are errors (and as you said there are no errors reported) so it goes back to perhaps moving to the correct record, other than that I have nothing else to offer.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my webpage under my profile but do not reply to forum questions.
    Microsoft Developer tools
    Developer’s Guide to Windows 10 video series

    Monday, September 21, 2015 12:39 PM
  • Kevin,

    While the problem has not yet been solved, I have learned something about why the problem occurs.

    All of this occurs in the form load event.

    The first activity of the event is that the various tables used in the form are filled.  The next activity is a set of cases that define which record is to be displayed in the form.  The case that is giving me trouble does not update the record when the save button is clicked. 

    What I started with was the following:

    Me.TblMBItemMasterTableAdapter.qryGetByItemNum(Me._ItemMaster_1_0DataSet.tblMBItemMaster)

    This did indeed display the record of interest in the form.  However, I could get no update when I ran the following code:

    Me.Validate()

    Me.TblMBItemMasterBindingSource.EndEdit()

    Me.TableAdapterManager.UpdateAll(Me._ItemMaster_1_0DataSet)

    It became apparent that the problem is probably associated with the fact that there is no binding source used in the case.  I did a lot of playing around and finally came up with this:

    Me.TblMBItemMasterTableAdapter.qryGetByItemNum(Me._ItemMaster_1_0DataSet.tblMBItemMaster)

    Me.TblMBItemMasterBindingSource.Position = 1

    While the appropriate record is displayed I am still not getting any update when I click the save button to run the update code.

    I am at a loss as to how to deal with this.


    gwboolean

    Monday, September 21, 2015 4:11 PM
  • Hi gwboolean,

    Could you please share a repro project with us? We would help test it and I think this is a very effective approach to help identity the caused reason and find the corresponded workaround.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, September 29, 2015 1:29 AM
    Moderator