IBCPSession::BCPExec (OLE DB)
Performs the bulk copy operation.
The BCPExec method copies data from a user file to a database table or vice versa, depending on the value of the eDirection parameter used with the IBCPSession::BCPInit method.
Before calling BCPExec, call the BCPInit method with a valid user file name. Failure to do so results in an error. The only exception is if a query is to be used for a bulk copy out operation. In that case specify NULL for the table name in the BCPInit method and then specify the query using the BCP_OPTION_HINTS option.
The BCPExec method is the only bulk copy method that is likely to be outstanding for any length of time. It is therefore the only bulk copy method that supports asynchronous mode. To use asynchronous mode, set the provider specific session property SSPROP_ASYNCH_BULKCOPY to VARIANT_TRUE before calling the BCPExec method. This property is available in the DBPROPSET_SQLSERVERSESSION property set. To test for completion, call the BCPExec method with the same parameters. If the bulk copy has not yet completed, the BCPExec method returns DB_S_ASYNCHRONOUS. It also returns in the pRowsCopied argument a status count of the number of rows that have been sent to or received from the server. Rows sent to the server are not committed until the end of a batch has been reached.