FAQs about Command

  1. I guess that the function COSession::ExecuteSQL inside creates a temporary command object for executing a statement. If I have a considerable number of statements, it may run slowly because the function has to create a  temporary command object repeatedly. How can I improve the speed of executing bulk statements?
      
         Your assumption is correct. However, OleDBPro encourages you to use CBatchParam<T> to execute bulk statements for the best speed without involvement of complex codes. For how to use it, see the example MultiProcs. However, if you don't want to use the template for some particular reasons, you can easily subclass a new class from CCmndBase to avoid creating a temporary command object for each of statements and may increase the speed somewhat.

  2. Do I need to prepare a parameterized statement or stored procedure for the best speed?
            In regards to this question, the answer is mainly up to how many times a parameterized statement or stored procedure will be repeatedly executed. If it is executed one time only, you don't have to prepare it and its preparation will not improve execution speed. If it is executed multiple times, it is necessary to do so for most of providers. If possible, you'd better to write a small test program to check if the preparation is necessary for the best speed. See the functions CBatchParam<T>::Open and CBullkRecordParam<T>::Open.