PreExecute event of ELS-QB component is fired when the user initiates  the execution of a query within ELS-QB Component and it is the first thing that occurs in the internal query processing chain of ELS-QB component. It occurs before the SQL text is validated against the back-end database and before the internal SQL parsing.

Such a behavior of PreExecute event will take user a chance to manipulate the SQL text in the PreExecute event, which in turn allows implementation of a custom mechanisms for running parameterized queries in the host application.

The following VC++ pseudo code illustrates the possible usage of this feature of ELS-QBcomponent:

           void CELS_QBDemoView::OnPreExecuteElsqbctrl()


              // the CParamDlg is a CDialog derived class in the host application

             // via which the user will enter the query parameter value.

             // Labels and text-boxes in such a dialog

             // may be dynamically created depending on the number of

             // parameter variables for the parameterized query

             CString strSQL, strFldName;

             int   nPos;

             // get the current SQL text to check for ?-symbols

             strSQL = m_QBCtrl.GetSQLText();

              nPos = strSQL.Find(_T('?'));

              if(nPos >= 0)


                   // calculate word length and using Mid() function

                   // get strFldName as the word following ?-symbol

                   // pass this parameter name to the CParamDlg

     // to update static control field Name

                   CParamDlg dlg;

                   dlg.m_statFieldName = strFldName;

             if(dlg.DoModal() == IDOK)


                   strSQL = strSQL.Left(nPos);

                   strSQL = strSQL + dlg.m_strValue;


                   // since CancelExecute was not called, automatically

                   // proceed with the execution of the query



                   // the user clicked Cancel button, so cancel

                   // the query execution