System.Data.SqlClient Namespace
Represents the method that will handle the RowUpdated event of an SqlDataAdapter.
[ VB ]
Public Delegate Sub SqlRowUpdatedEventHandler ( _
ByVal sender As Object, _
ByVal e As SqlRowUpdatedEventArgs _
)
[ C# ]
public delegate void SqlRowUpdatedEventHandler (
object sender,
SqlRowUpdatedEventArgs e
);
[ C++ ]
public __gc __delegate void SqlRowUpdatedEventHandler (
Object* sender,
SqlRowUpdatedEventArgs* e
);
In [ JScript ], you can use the delegates in the .NET Framework, but you cannot define your own.
The declaration of your event handler must have the same parameters as the
SqlRowUpdatedEventHandler delegate declaration.
- sender
- The source of the event.
- e
- The SqlRowUpdatedEventArgs that contains the event data.
The handler is not required to perform any action, and your code should avoid
generating exceptions or allowing exceptions to propagate to the calling method.
Any exceptions that do reach the caller are ignored.
When you create an SqlRowUpdatedEventArgs delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate.
For more information about event handler delegates, see Web Forms Events and Handlers.
The following shows how to programmatically add and remove a RowUpdated event handler.
// add handler
myAdapter.RowUpdated += new OleDbRowUpdatedEventHandler ( OnRowUpdated );
myAdapter.Update ( custDS, "Customers" );
// remove handler
myAdapter.RowUpdated -= new OleDbRowUpdatedEventHandler ( OnRowUpdated );
' add handler
AddHandler myAdapter.RowUpdated, _
New OleDbRowUpdatedEventHandler ( AddressOf OnRowUpdated )
myAdapter.Update ( custDS, "Customers" )
' remove handler
RemoveHandler myAdapter.RowUpdated, _
New OleDbRowUpdatedEventHandler ( AddressOf OnRowUpdated ) |
|
C# |
VB |
The following shows how to code a simple handler that receives control whenever the RowUpdated event occurs. Here, the handler simply prints out the event arguments.
void OnRowUpdated ( object sender, SqlRowUpdatedEventArgs e ) {
string args = "OnRowUpdated event args: <br>";
args += " command=" + e.Command + "<br>";
args += " commandType=" + e.StatementType + "<br>";
args += " recordsAffected=" + e.RecordsAffected + "<br>";
args += " status=" + e.Status;
Response.Write ( args );
}
Sub OnRowUpdated ( sender As Object, e As SqlRowUpdatedEventArgs )
dim args as string = "OnRowUpdated event args: <br>"
args = args & " command=" & e.Command & "<br>"
args = args & " commandType=" & e.StatementType & "<br>"
args = args & " recordsAffected=" & e.RecordsAffected & "<br>"
args = args & " status=" & e.Status
Response.Write ( args )
End Sub |
|
C# |
VB |
SqlDataAdapter.RowUpdated Event SqlRowUpdatedEventArgs Class