VB.net Trapping MySql TableAdapter Event

Hello Experts!

I want to trap the MySql RowUpdated event. From all that I have read I thought the following code would do it but it's not triggering. It's been a few months since I've done vb coding so it could be that I just missed something obvious.

I am using VB.net 2005 with the latest MySql adapter.

You help is greatly appreciated.

Here is the code as I have been able to figure it out:

Namespace TRUWESTDataSetTableAdapters

  Partial Public Class MySqlRowUpdatedEventArgs

    Public Delegate Sub MySqlRowUpdatedEventHandler(ByVal sender As Object, ByVal e As MySqlRowUpdatedEventArgs)

    Public Event RowUpdated As MySqlRowUpdatedEventHandler

    Sub _RowUpdated(ByVal sender As Object, ByVal e As MySqlRowUpdatedEventArgs) Handles Me.RowUpdated

      Console.WriteLine("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")

    End Sub

  End Class
End Namespace
LVL 1
RegProctorAsked:
Who is Participating?
 
ToFroConnect With a Mentor Commented:
That should of course have been:
Private WithEvents adapter As MySqlDataAdapter

Then this usually works:
Private Sub adapter_RowUpdated(ByVal sender As System.Object, ByVal e As MySqlRowUpdatedEventArgs) Handles adapter.RowUpdated
   ' Do the magic
End Sub
0
 
ToFroCommented:
Have you declared the MySqlDataAdapter WithEvents?

private withevents adapter as SqlDataAdapter
0
 
RegProctorAuthor Commented:
It's looking better, but now I am getting an error. Here is what I have:

Namespace TRUWESTDataSetTableAdapters

  Partial Public Class MySqlRowUpdatedEventArgs
    Public WithEvents adapter As MySqlDataAdapter

    Public Sub adapter_RowUpdated(ByVal sender As Object, ByVal e As MySqlRowUpdatedEventArgs) _
      Handles adapter.RowUpdated
      ' Do the magic
    End Sub

  End Class
End Namespace

And here's the error:

Error      1      Method 'Public Sub adapter_RowUpdated(sender As Object, e As truWest.TRUWESTDataSetTableAdapters.MySqlRowUpdatedEventArgs)' cannot handle Event 'Public Event RowUpdated(sender As Object, e As MySql.Data.MySqlClient.MySqlRowUpdatedEventArgs)' because they do not have the same signature.      J:\truWest\Order Processing - Internal\VB.Net\truWest\DB.vb      120      23      truWest

I then found the rowupdated event and copied the structure from the Object Browser and got this:

Public Sub adapter_RowUpdated(ByVal sender As Object, ByVal e As truWest.TRUWESTDataSetTableAdapters.MySqlRowUpdatedEventArgs) Handles

Using that with handles added as such:

Public Sub adapter_RowUpdated(ByVal sender As Object, ByVal e As truWest.TRUWESTDataSetTableAdapters.MySqlRowUpdatedEventArgs) Handles  adapter.RowUpdated

Gives the same error.

0
 
RegProctorAuthor Commented:
Thanks. Got it. From what you showed with some fiddling I got this which works:

Namespace TRUWESTDataSetTableAdapters
  Partial Public Class color_palettesTableAdapter
    Public Sub adapter_RowUpdated(ByVal sender As Object, ByVal e As MySqlRowUpdatedEventArgs) Handles _adapter.RowUpdated
      'GetAutoIncrementNo(e)
    End Sub
  End Class
End Namespace
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.