CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2014
    Posts
    3

    bindingsource.endedit fails first time it is called, succeeds otherwise

    (I'm using VS 2012 on a Windows 8.1 machine; building an app that talks to MS Access.)

    Overview: on my main form I have a datagridview; the user may select a row, and via a menu option bring up a "detail" form that lets the user edit data for a specific record. That form has (among others) two menu items, "Save & Close" and "Cancel & Close".

    The bizarre behavior is that the *first time* I bring up the detail form, make changes and do "Save & Close", the changes aren't saved to the underlying database. Every time after that they are, which makes it difficult to figure out how the code might be wrong. My first question: has anyone else seen anything like this behavior?

    There is nothing in the detail form's LOAD event that might be to blame.

    I used Visual Studio's 'wizards' or whatever they're called to bring in the dataset, and there is a *lot* of autogenerated code; I suspect a bug in there somewhere, but after several readthroughs have found nothing.

    The "Save" part, invoked from the menu, (loosely - I'll use "BindSrc" for the binding source name) does:
    Me.Validate()
    Me.BindSrc.EndEdit()
    Me.TableAdapterManager.UpdateAll(Me.Maindataset)

    (A variant that just does the Update on the specific table adapter makes no difference.)

    The system itself is a bit more complicated, with multiple datagrids on multiple forms, linked together in various ways - not trivial for me to quote the code in detail without being both voluminous and tedious.

    I think what's driving me slightly nuts is that the code as written works, without errors, every time after the first use of the form. Consequently I don't think I'm missing some key function or method call; rather, it is a state-based problem, and I have no way to get in to (say) EndEdit to see what state information it might be using.

    Any suggestions would be most appreciated.

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: bindingsource.endedit fails first time it is called, succeeds otherwise

    I would guess that it might be due to how the object has been initialized; or perhaps even a scoping issue

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

Featured