<< Return to Main Index

< Return to Class Index

class CGXADOEngine : public CGXScrollableCurEngine

This is an implementation of CGXDBEngine that binds to ADO.

The engine has to be initialized with a valid ADO recordset. Here is an example:

ADORecordset* pAdoRecordset = CGXADOEngine::CreateRecordset(m_strSource.AllocSysString(),m_strSQL.AllocSysString());

if(pAdoRecordset)
      // pAdoRecordset will be closed and released in the engine's destructor.
      m_pDBEngine = new CGXADOEngine(pAdoRecordset);

There is also a member-function variant for the above constructor which you can use to initialize an engine created with the default constructor or re-initialize the engine at a later time:

void Init(ADORecordset* pSet, BOOL bIsOpen = TRUE);

Internally, the engine gets in sync with the recordset cursor (storing the current position in an internal data member and updating it as the cursor gets moved around) and as the request for data from a particular record comes in, it moves the cursor to the right position to fetch data from the requested record.

Here is how you would initialize the grid with the ADO engine:

void CAdoEngView::OnInitialUpdate()
{
   // Grid takes a pointer to the abstract interface CGXDBEngine.
   // whereas the object itself is a CGXADOEngine an implementation of CGXDBEngine.
   SetEngine(m_pDBEngine, NULL, FALSE);
   // Implementation(ADO) specific initailization function. Derives from a base template
   // Always call this after SetEngine.
   m_pLayoutManager->m_pfInitFunction = GXInitDBEGridFromADOEngine;

   // Call the base class.
   CGXDBEGrid < CGXGridView >::OnInitialUpdate();
   … …
}

Using this ADO engine to bind the grid to an ADO recordset is an alternative to using our pre-bound CGXADOGrid (a CGXBrowserGrid subclass). We recommend that you use the CGXADOGrid way of binding the grid to ADO. We implemented this ADO engine to be used for binding hierarchical grids to hierarchical ADO data. So, unless you are interested in viewing hierarchical ADO data in the grid (in which case you should be working with CGXHierADOEngine) we recommend you not to use this class.

See Also

CGXADOGrid CGXHierADOEngine CGXScrollableCurEngine CGXDBEngine

CGXADOEngine

Class Members