Int rowCount = cmd.EndExecuteNonQuery( res ) This blocks until the command completes. IAsyncResult res = cmd.BeginExecuteNonQuery() The following code is the C# language equivalent: ' This blocks until the command completes. + " SET DepartmentName = 'Engineering'" _ There are four ways to wait for execution to complete:Ĭall EndExecuteNonQuery Calling EndExecuteNonQuery blocks until the command completes. If an error occurs while executing the command, the exception is thrown when the EndExecuteNonQuery method is called. It is an error to call the EndExecuteNonQuery method to end a call to the BeginExecuteReader method, and vice versa. Passed to the EndExecuteNonQuery method must be the same as the one returned from the BeginExecuteNonQuery call that is beingĬompleted. ADO.NET is not thread safe you must ensure that the BeginExecuteNonQuery call has returned. The call must be made after the BeginExecuteNonQueryĬall returns. Platforms:Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family, Windows 7, Windows 8, Windows 10, Windows Server 2012 family.You must call the EndExecuteNonQuery method once for every BeginExecuteNonQuery call. M圜ommand.CommandText = "INSERT INTO DEPT VALUES (50,'Development','Philadelphia')"Ĭonsole.WriteLine( "Starting asynchronous query execution.")ĭim cres As IAsyncResult = m圜ommand.BeginExecuteNonQuery( Nothing, Nothing)Ĭonsole.WriteLine( "Have to wait for operation to complete.")Įnd If Try Dim RowsAffected As Integer = m圜ommand.EndExecuteNonQuery(cres)Ĭonsole.WriteLine( String.Concat( "Rows affected: ", RowsAffected.ToString()))Ĭonsole.WriteLine( String.Concat( "An exception has occurred: ", e.Message)) Public Sub Async_Exec( ByVal m圜onnection As DbConnectionBase)ĭim m圜ommand As DbCommandBase = m圜onnection.CreateCommand()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |