Ends an asynchronous invocation of the
Open method.
This sample shows how to implement asynchronous opening of a connection.
|
|---|
public void AsyncOpen(DbConnectionBase myConnection)
{
IAsyncResult myAsyncResult = myConnection.BeginOpen(null, null);
DbCommandBase myCommand = (DbCommandBase)myConnection.CreateCommand();
myCommand.CommandText = "INSERT INTO Dept(DeptNo, DName) Values('100', 'DEVELOPMENT')";
//some operations here
myConnection.EndOpen(myAsyncResult);
try
{
myCommand.ExecuteNonQuery();
}
finally
{
myConnection.Close();
}
} |
|
|---|
Public Sub AsyncOpen(ByVal myConnection As DbConnectionBase)
Dim myAsyncResult As IAsyncResult = myConnection.BeginOpen(Nothing, Nothing)
Dim myCommand As DbCommandBase = myConnection.CreateCommand()
myCommand.CommandText = "INSERT INTO Dept(DeptNo, DName) Values('110', 'QA')"
' some operations here
myConnection.EndOpen(myAsyncResult)
Try
myCommand.ExecuteNonQuery()
Finally
myConnection.Close()
End Try
End Sub |