[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VB.net Trapping MySql TableAdapter Event

Posted on 2007-07-23
4
Medium Priority
?
1,006 Views
Last Modified: 2008-01-09
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
0
Comment
Question by:RegProctor
  • 2
  • 2
4 Comments
 
LVL 6

Expert Comment

by:ToFro
ID: 19546105
Have you declared the MySqlDataAdapter WithEvents?

private withevents adapter as SqlDataAdapter
0
 
LVL 6

Accepted Solution

by:
ToFro earned 2000 total points
ID: 19546129
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
 
LVL 1

Author Comment

by:RegProctor
ID: 19552219
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
 
LVL 1

Author Comment

by:RegProctor
ID: 19552265
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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question