I would like to know as I can use a database Access (CDB)
in eVC++. If somebody will have some example of code will
go to help.
I am trying to use the following code:

BOOL CEXADOCEDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// Set the icon for this dialog. The framework
does this automatically
// when the application's main window is not a
dialog
SetIcon(m_hIcon, TRUE); // Set big
icon
SetIcon(m_hIcon, FALSE); // Set
small icon

//Make the Window Wider so the title bar is
viewable
if (!SetWindowPos(this,0,0,480,200,SWP_NOZORDER |
SWP_NOMOVE)) {
AfxMessageBox(_T("Error Resizing Current
Window."));
}

CenterWindow(GetDesktopWindow()); // center
to the hpc screen

//Create the ADOModule
m_pADOMod = new ADOModule();

//Initialize the ADOModule
if (FAILED(m_pADOMod->Initialize())) {
AfxMessageBox(_T("Database support cannot
be initialized\r\n")
_T("Please make sure that you have
the proper database on\r\n")
_T("your device, and that your
device supports ADOCE."));
}

return TRUE; // return TRUE unless you set the
focus to a control
}

/////////////////////////////////////////////////////////


HRESULT ADOModule::Initialize()
{
TCHAR szFilter[] = _T("MS-Access Files
(*.cdb)|*.cdb|");

//You are required to pick the database file to be
working with
CFileDialog cfd(TRUE,_T
("cdb"),NULL,OFN_FILEMUSTEXIST,
(LPCTSTR)szFilter,NULL);

if (cfd.DoModal() == IDOK) {

//Store the path of the database file for
later use
m_strFilePath = cfd.GetPathName();

//Initialize the COM system:
//Note that the Multithreaded flag is the
only
//one supported in Windows CE at this time.
if (FAILED(CoInitializeEx(NULL,
COINIT_MULTITHREADED))) {
AfxMessageBox(_T("Error
initializing COM"));
return E_FAIL;
}

//Get the Recordset interface
if (FAILED(CoCreateInstance
(CLSID_ADOCERecordset, NULL,

CLSCTX_INPROC_SERVER, IID_IADOCERecordset,

(void**)&m_pIRecordSet))) {
AfxMessageBox(_T("Could not load
ADOCE"));
return E_FAIL;
}

//Change class state to initialized state
m_bInit = TRUE;

//Make sure that we're dealing with a
database that this
//sample application can work with.
if (!VerifyCompatible(TRUE)) {
return E_FAIL;
}

return S_OK;
}
return E_FAIL;
}


///////////////////////////////////////////////////////////

BOOL ADOModule::VerifyCompatible(BOOL bShow)
{
long size = 0;
HRESULT hr;
COleVariant source;
COleVariant connStr;
CursorTypeEnum cte = adOpenKeyset;
LockTypeEnum lte = adLockReadOnly;

//Check to make sure that the 'ToyTable' table
exists
source.SetString(_T("ToyTable"),VT_BSTR);
connStr.SetString((LPCTSTR)m_strFilePath,VT_BSTR);

//Open the table
hr = getRecordSet()->Open
(source,connStr,cte,lte,adCmdTable);
if (FAILED(hr)) {
return FALSE;
}

//And get the record Count
hr = getRecordSet()->get_RecordCount(&size);
if (FAILED(hr)) {
return FALSE;
}

CString strMsg;
strMsg.Format(_T("'ToyTable' table opened properly
with %ld records.\r\n"),size);

//Close the 'ToyTable' recordSet
hr = getRecordSet()->Close();
if (FAILED(hr)) {
return FALSE;
}

if (bShow) {
AfxMessageBox(strMsg);
}
return TRUE;
}



However he is not functioning. I need a urgent aid. The
2,12 version of windows ce that I am using is and the
processor i486.

ADOCE in WinCE 2.12 (forever) by Chris

Chris
Mon Oct 27 17:23:14 CST 2003

Make sure that you have the adoce31.dll and adoxce31.dll
and adocedb31.dll(i think this the right spelling) on the
handheld. You might also want to search for something
called VDORecordSet, it is a free MFC wrapper for ADOCE
and makes it fairly easy to work with ADOCE.

>-----Original Message-----
>I would like to know as I can use a database Access
(CDB)
>in eVC++. If somebody will have some example of code
will
>go to help.
>I am trying to use the following code:
>
>BOOL CEXADOCEDlg::OnInitDialog()
>{
> CDialog::OnInitDialog();
>
> // Set the icon for this dialog. The framework
>does this automatically
> // when the application's main window is not a
>dialog
> SetIcon(m_hIcon, TRUE); // Set
big
>icon
> SetIcon(m_hIcon, FALSE); // Set
>small icon
>
> //Make the Window Wider so the title bar is
>viewable
> if (!SetWindowPos(this,0,0,480,200,SWP_NOZORDER |
>SWP_NOMOVE)) {
> AfxMessageBox(_T("Error Resizing Current
>Window."));
> }
>
> CenterWindow(GetDesktopWindow()); // center
>to the hpc screen
>
> //Create the ADOModule
> m_pADOMod = new ADOModule();
>
> //Initialize the ADOModule
> if (FAILED(m_pADOMod->Initialize())) {
> AfxMessageBox(_T("Database support cannot
>be initialized\r\n")
> _T("Please make sure that you
have
>the proper database on\r\n")
> _T("your device, and that your
>device supports ADOCE."));
> }
>
> return TRUE; // return TRUE unless you set the
>focus to a control
>}
>
>/////////////////////////////////////////////////////////
>
>
>HRESULT ADOModule::Initialize()
>{
> TCHAR szFilter[] = _T("MS-Access Files
>(*.cdb)|*.cdb|");
>
> //You are required to pick the database file to
be
>working with
> CFileDialog cfd(TRUE,_T
>("cdb"),NULL,OFN_FILEMUSTEXIST,
> (LPCTSTR)szFilter,NULL);
>
> if (cfd.DoModal() == IDOK) {
>
> //Store the path of the database file for
>later use
> m_strFilePath = cfd.GetPathName();
>
> //Initialize the COM system:
> //Note that the Multithreaded flag is the
>only
> //one supported in Windows CE at this
time.
> if (FAILED(CoInitializeEx(NULL,
>COINIT_MULTITHREADED))) {
> AfxMessageBox(_T("Error
>initializing COM"));
> return E_FAIL;
> }
>
> //Get the Recordset interface
> if (FAILED(CoCreateInstance
>(CLSID_ADOCERecordset, NULL,
>
> CLSCTX_INPROC_SERVER, IID_IADOCERecordset,
>
> (void**)&m_pIRecordSet))) {
> AfxMessageBox(_T("Could not load
>ADOCE"));
> return E_FAIL;
> }
>
> //Change class state to initialized state
> m_bInit = TRUE;
>
> //Make sure that we're dealing with a
>database that this
> //sample application can work with.
> if (!VerifyCompatible(TRUE)) {
> return E_FAIL;
> }
>
> return S_OK;
> }
> return E_FAIL;
>}
>
>
>/////////////////////////////////////////////////////////
//
>
>BOOL ADOModule::VerifyCompatible(BOOL bShow)
>{
> long size = 0;
> HRESULT hr;
> COleVariant source;
> COleVariant connStr;
> CursorTypeEnum cte = adOpenKeyset;
> LockTypeEnum lte = adLockReadOnly;
>
> //Check to make sure that the 'ToyTable' table
>exists
> source.SetString(_T("ToyTable"),VT_BSTR);
> connStr.SetString((LPCTSTR)m_strFilePath,VT_BSTR);
>
> //Open the table
> hr = getRecordSet()->Open
>(source,connStr,cte,lte,adCmdTable);
> if (FAILED(hr)) {
> return FALSE;
> }
>
> //And get the record Count
> hr = getRecordSet()->get_RecordCount(&size);
> if (FAILED(hr)) {
> return FALSE;
> }
>
> CString strMsg;
> strMsg.Format(_T("'ToyTable' table opened
properly
>with %ld records.\r\n"),size);
>
> //Close the 'ToyTable' recordSet
> hr = getRecordSet()->Close();
> if (FAILED(hr)) {
> return FALSE;
> }
>
> if (bShow) {
> AfxMessageBox(strMsg);
> }
> return TRUE;
>}
>
>
>
>However he is not functioning. I need a urgent aid. The
>2,12 version of windows ce that I am using is and the
>processor i486.
>.
>