Now, to test these events you can write code that fills a dataset and calls the update method of data adapter.
I added an event handler for the button by double- clicking on it and writing the code shown in listing 9-6.
This enables you to provide an event-handling method that performs a custom routine, such as checking the results of the update operation, whenever this event occurs.
You can also indicate whether the exception was handled in the event-handling method by setting the P: System.
After that I changed the button's name property to Data Adapter Events Test Btn and wrote a button-click event handler by double-clicking on the button control.
As you can see from Listing 9-5, you can compare the Statement Type member of Ole Db Row Updating Event Args to the Statement Type enumeration to find out the statement type.
The Statement Type enumeration defines Select, Insert, Update, and Delete members.
' Assumes that connection is a valid Sql Connection object.
Dim cust Adapter As Sql Data Adapter = New Sql Data Adapter( _ "SELECT Customer ID, Company Name FROM Customers", connection) ' Add handlers. Row Updating, New Sql Row Updating Event Handler( _ Address Of On Row Updating) Add Handler cust Adapter. Row Updating, _ New Sql Row Updating Event Handler(Address Of On Row Updating) Remove Handler cust Adapter.