MySql.Data.MySqlClient.MySqlCommand.EndExecuteNonQuery C# (CSharp) Method

EndExecuteNonQuery() public method

Finishes asynchronous execution of a SQL statement.
public EndExecuteNonQuery ( IAsyncResult asyncResult ) : int
asyncResult IAsyncResult The returned by the call /// to .
return int
		public int EndExecuteNonQuery(IAsyncResult asyncResult)
		{
			asyncResult.AsyncWaitHandle.WaitOne();
            AsyncDelegate c = caller;
            caller = null;
            if (thrownException != null)
                throw thrownException;
            return (int)c.EndInvoke(asyncResult);
		}

Usage Example

Exemplo n.º 1
0
 public static void EjecutarQuery(string querySQL, MySqlConnection connection)
 {
     try
         {
             MySqlCommand command = new MySqlCommand(querySQL, connection);
             connection.Open();
             IAsyncResult result = command.BeginExecuteNonQuery();
             while (!result.IsCompleted)
             {
                 Thread.Sleep(50);
             }
             command.EndExecuteNonQuery(result);
             connection.Close();
         }
         catch (SqlException ex)
         {
             throw ex;
         }
         catch (InvalidOperationException ex)
         {
             throw ex;
         }
         catch (MySqlException ex)
         {
             //Se captura en el caso de intentar guardar un cliente que ya esta en
             //la base de datos. Como no me interesa guardarlo, no hago nada.
             if (ex.Message.IndexOf("PRIMARY", StringComparison.Ordinal) <= 0)
                 throw ex;
         }
 }
All Usage Examples Of MySql.Data.MySqlClient.MySqlCommand::EndExecuteNonQuery