CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Guest

    CDaoDatabase troubles in Visual C++ v6.0 Service Pack 2

    Has anyone else had trouble with their CDaoDatabase programs when compiling under Visual C++ 6.0 Service Pack 2?

    The following code worked under v5.0 but now throws an exception.


    CDaoDatabase myDatabase;

    myDatabase.Open( "C:\MyDB.mdb" );




    I have also tryed downloading some of the CDaoDatabase examples provided on this site, and those do not seem to work either. The problem appears to exist in the AfxDaoInit() function. I used the Visual Debugger to trace the problem to this function, and I noticed from some of the CDaoDatabase apps on this site, that they also suffer from the problem.

    If anyone has any idea what the problem is or can offer a solution, I would appreciate it. Thanks in advance.




  2. #2
    Join Date
    May 1999
    Posts
    35

    Re: CDaoDatabase troubles in Visual C++ v6.0 Service Pack 2

    If you step in to the source code of the CDaoDatabase->Open"() Method you will find that the wrapper class for the DAOEngine is trying to Initlize the DBEngine.They have function called AfxDaoInit() inside the Open call of CDaoDatabase.And very first line of the function AfxDaoInit() is calling ::CoInitlze(NULL).But you know what your App already called ::CoInitlize(NULL).DAOEngine is register as Apartment Model in to registery.It means you can not create Instance of DBEngine from MTA.It will always give you error code "0x80010106".And description is says "Thread Mode cannot be set by Another process".
    To get rid of this problem You have to use DBEngine as a COM object .Don not use wrapper calss i.e CDaoDatabase classes.
    Ksheeraj

    39639,Leslie St.
    Apt #157
    Fremont USA 94538

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured