none
Binding navagator code generator is creating errors RRS feed

  • Question

  • I have a simple form when I drag and drop fields from the data source it generates a Binding navigator. But the code it generates for navigator is causing errors on build. Below is the code it generates. The error is:
            "Handles clause requires a WithEvents variable defined in the containing type or one of its base types."
    I get 8 errors one error for each of the MyBaseBindingNavigatorSaveItem.Click clauses.

    Private Sub Shift_LogBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) 
    Handles MyBaseBindingNavigatorSaveItem.Click, MyBaseBindingNavigatorSaveItem.Click, 
    MyBaseBindingNavigatorSaveItem.Click, MyBaseBindingNavigatorSaveItem.Click, 
    MyBaseBindingNavigatorSaveItem.Click, MyBaseBindingNavigatorSaveItem.Click, 
    MyBaseBindingNavigatorSaveItem.Click, MyBaseBindingNavigatorSaveItem.Click
    
    Me.Validate()
    Me.Shift_LogBindingSource.EndEdit()
    Me.TableAdapterManager.UpdateAll(Me.LazerMaintenanceDataSet)
    
    End Sub

    The fix is simple but there is a problem with the code generation of visual studios, should be

        Private Sub Shift_LogBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) _
                    Handles Shift_LogBindingNavigatorSaveItem.Click
            Me.Validate()
            Me.Shift_LogBindingSource.EndEdit()
            Me.TableAdapterManager.UpdateAll(Me.LazerMaintenanceDataSet)
    
        End Sub

    Tuesday, August 20, 2019 2:02 PM

All replies

  • Hi,

    Sorry, I have tried to reproduced the issue, but it failed. "BindingNavigatorSaveItem.Click" has not been repeated multiple times (both in VS2017 & VS2019). Everything looks normal.

    Regards,

    Kyle


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, August 21, 2019 1:24 AM
    Moderator
  • Hello,

    I've been on the forums since 2008, have seen a lot of code generation with Visual Studio's data wizards but have never seen code generation add multiples to a Handles. 

    At this point in time Microsoft is not going to look into this as their focus is web based these days.

    Questions, is this the first time or not you have uses TableAdapter method to work with data and not have this problem? What version of Visual Studio are you using?


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Wednesday, August 21, 2019 10:39 AM
    Moderator
  • I am using VS 2015. This is not the first time this has happened, its just the first time I have reported it. Could it be a recent fix to one of other products in VS has caused this issue? Over the last two years we here Globe Marketing Services have struggled to upgrade all of our VB6, 2008 and 2010 to 2015. I really hope now that we have managed to get most of the conversion done your not saying upgrade again. We still have SS2008 servers which require us to still maintain some older software. As it is most of our developers have multiple versions of VS installed. I'm sorry can't rewrite all our internal applications every time MS decides to put out a new version of VS. Surly you can see that's not practical. If Microsoft is not supporting this software perhaps it should sell the product to a company the will, either that or discount the subscriptions for companies that are developing in house internal applications, just a idea. I feel like I'm paying for a defective product with no support. Personally I have long felt Microsoft has been trying to pack way to much into its Visual Studios Development software. This seems like a clear line that might facilitate a product split. Anyway thank you for listening and trying to help.




    Wednesday, August 21, 2019 1:07 PM
  • I feel your pain, sometimes it's good to vent.

    Have you considered not using data wizards but instead using a more drawn out approach such as going right to the managed provider with a connection, command and command parameters? Or any consideration to using Entity Framework 6 (Entity Framework Core only has advantages that are seen mostly in ASP.NET).

    In regards to Entity Framework, if it's a consideration at some point look at Code first with existing databases as the approach using .EDMX can be problematic with large relational databases e.g. 30 plus tables.

    My former company we moved as follows which spanned about five years

    • VB6 to VB.NET with data wizards
    • VB.NET with manage data provider
    • C# with managed data provider
    • C# with Entity Framework 6

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Wednesday, August 21, 2019 6:54 PM
    Moderator
  • Hi,

    First, sorry for the inconvenience.

    I have reported the problem on the Developer Community. There, someone will help you handle this issue. Here is the link:

    Event BindingNavigatorSaveItem.Click binding issue

    You can track the progress on this page.

    Regards,

    Kyle


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, August 22, 2019 1:43 AM
    Moderator