?
Solved

DAO database initialization

Posted on 1998-12-01
1
Medium Priority
?
276 Views
Last Modified: 2012-05-04
My application is a Win32 console application, using MFC as a static library.  When I execute the following code I get a strange problem.  When the AfxDaoInit() function is called I am not able to clear the history list of iexplorer 4.0 . (From the view menu select the internet options , clear history). iexplorer application doesnot respond until my application exits. The code is as below.

#include <afxdao.h>
#include <windows.h>


int main()
{
      CDaoDatabase obj_Database;

      AfxDaoInit();
      try
      {
      obj_Database.Open("mydata.mdb", FALSE, FALSE);
      }
      catch (CDaoException* e)
      {      
            int iIndex;
            
            for(iIndex = 0; iIndex < e->GetErrorCount(); iIndex++)
            {
                  e->GetErrorInfo(iIndex);
                  printf("%s\n", (e->m_pErrorInfo)->m_strDescription);
            }
            return(FALSE);
      }
      getchar(); // this is to keep my app running.
      db.Close();
      obj_Database.Close();
      AfxDaoTerm();
      return(TRUE);
}
0
Comment
Question by:necjc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
necfm earned 400 total points
ID: 1969738
The problem is that COM  creates an invisible window which must have a message loop running. When IE generates "broadcast" messages the desktop will hang if not all windows respond!
The AfxDaoInit() probably calls CoInitialize() which creates a new COM-apartment (and a window), you have to dispatch messages in this thread to avoid these problems and also to get COM to work.
A simple loop like this will solve the problem in your test program:Replace getchar(); with

  MSG msg;
  while (GetMessage(&msg,NULL,0,0) == 1) {
   TranslateMessage(&msg);
   DispatchMessage(&msg);
}

0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question