<< Return to Main Index

< Return to Class Index

class CGXHierADOEngine : public CGXADOEngine

Remarks

This is an implementation of CGXDBEngine that binds to ADO and also supports exposing hierarchical ADO data (provided it is supplied a valid ADO recordset with hierarchical data).

The supplied ADO recordset should have been created with an ADO shape command and with the ADO Shape provider. This class implements the GetChildAt interface exposed by CGXDBEngine there by allowing clients to get (hierarchical) child information.

Here is some sample code on how you could initialize the engine and bind it to a hierarchical DBEngine grid.

In your document class:

BOOL CAdoHierDoc::OnNewDocument()
{
   … …
   m_strSource = _T("Provider=MSDataShape;Data Source=Northwind;"); lpcszSource;
   m_strSQL = _T("SHAPE {select * from customers} APPEND ({select * from orders} AS rsOrders RELATE customerid To customerid)");

   m_pAdoRecordset = CGXADOEngine::CreateRecordset(m_strSource.AllocSysString(),m_strSQL.AllocSysString());

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

   return TRUE;
}

And in your view class:

class CAdoHierView : public CGXDBEHierGrid < CGXGridView >

void CAdoHierView::OnInitialUpdate()
{

   // Grid takes a pointer to the abstract interface CGXDBEngine.
   // whereas the object itself is a CGXHierADOEngine an implementation of CGXDBEngine.
   SetEngine(((CAdoHierDoc*)GetDocument())->m_pDBEngine, NULL, FALSE);
   // Implementation(ADO) specific initailization function. Derives from a base template
   // Always call this after SetEngine.
   m_pLayoutManager->m_pfInitFunction = GXInitHierGridFromADOEngine;

   CGXDBEHierGrid < CGXGridView >::OnInitialUpdate();
   … …
}

For more information take a look at our "Database Engine Architecture" in our User’s Guide and the Samples\Grid\Database\AdoHier sample.

See Also

CGXADOEngine CGXDBEngine CGXDBEHierGrid