Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

CDatabase::CDatabase

Constructs a CDatabase object.

CDatabase( );

After constructing the object, you must call its OpenEx or Open member function to establish a connection to a specified data source.

You may find it convenient to embed the CDatabase object in your document class.

This example illustrates using CDatabase in a CDocument-derived class.

// This fragment is taken from the declaration for CMyDatabaseDoc 
// CMyDatabaseDoc is derived from CDocument. 
public:
   // Declare a CDatabase embedded in the document
   CDatabase m_dbCust;
// Initialize when needed
CDatabase* CMyDatabaseDoc::GetDatabase()
{
   // Connect the object to a data source 
   if(!m_dbCust.IsOpen() && !m_dbCust.OpenEx(NULL))
      return NULL;

   return &m_dbCust;
}

Header: afxdb.h

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.