Newbie Question: Firing an Event handler

  • Thread starter Thread starter Bruce A. Julseth
  • Start date Start date
B

Bruce A. Julseth

SqlDataAdapter has the Event, RowUpdated. How do I set up a handler in my
code for when it fires?

I assume it would look something like,

Private Sub da_RowUpdated(byVal sender as System.Object, ByVal e as
SqlRowUpdatedEventArgs )

in my code. I don't know how to set it up.

Thanks...

Bruce
 
Hi,

Use addhandler. I am assuming the datadapter name is da.

AddHandler da.RowUpdated, AddressOf da_RowUpdated


http://msdn.microsoft.com/library/d...en-us/vblr7/html/vastmaddhandlerstatement.asp

Ken
------------------------------
SqlDataAdapter has the Event, RowUpdated. How do I set up a handler in my
code for when it fires?

I assume it would look something like,

Private Sub da_RowUpdated(byVal sender as System.Object, ByVal e as
SqlRowUpdatedEventArgs )

in my code. I don't know how to set it up.

Thanks...

Bruce
 
DA also has to be a class level variable declare WithEvents.
At this point you can use AddHandler in code to add the handler, or you
can add "Handles da.RowUpdated" to your da_RowUpdated method...

The line would look like this:

Private Sub da_RowUpdated(ByVal sender as System.Object, ByVal e as
SqlRowUpdatedEventArgs) Handles da.RowUpdated

Hope this helps,
Brian Swanson
 
Hi,

You dont need withevents if you are using addhandler.

Ken
-----------------
DA also has to be a class level variable declare WithEvents.
At this point you can use AddHandler in code to add the handler, or you
can add "Handles da.RowUpdated" to your da_RowUpdated method...

The line would look like this:

Private Sub da_RowUpdated(ByVal sender as System.Object, ByVal e as
SqlRowUpdatedEventArgs) Handles da.RowUpdated

Hope this helps,
Brian Swanson
 
Suggestions work like a charm.. Thanks to all...

BTW: Unless I did something wrong, I had to add the "WithEvents" when I
defined my data adapter object
Dim WithEvents da as new SqlDataAdapter
I removed it, as a test, and it wouldn't compile..

Thanks again...

Bruce
 
You had to add WithEvents if you used the "Handles da.Rowupdated"And not when you had used the AddHandler clause as Brian showed.

You have two ways to do it.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top