CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 1999
    Location
    ks
    Posts
    522

    Visual Studio Extracting Data from MSAccess Databases

    I had a wonderful life. I was able to develop a class, CAccessDBManager, to manage
    interactions between VC++ and MSAccess databases. Worked like a charm for years
    with VS2010 which went away and Office 2007. Now I am trying to use VS2022 and MSAccess that purports to be “Access 2007 – 2016 file format”.

    Here is the relevant portion of my class method, CAccessDBManager::OpenDatabase():

    void CAccessDBManager::OpenDatabase(){
    if ( ConnectionPtrIsOpen == FALSE ){
    _bstr_t bstrEmpty(L"");
    _variant_t vtEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);

    CoInitialize(NULL);
    try{ // to create an ADO _ConnectionPtr
    hr = ConnectionPtr.CreateInstance( __uuidof( Connection ) );
    ConnectionPtr->ConnectionString = ConnectionString;
    hr = ConnectionPtr->Open(bstrEmpty,bstrEmpty,bstrEmpty,-1); << ????
    ConnectionPtrIsOpen = TRUE;
    }
    catch( _com_error &e ){
    . . .
    }
    . . .
    }

    Connection string is:
    L"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\SomeDir\\SomeDB.accdb"

    Everything works as it should until I get to:
    hr = ConnectionPtr->Open(bstrEmpty,bstrEmpty,bstrEmpty,-1);


    these are the log entries.

    onecore\com\combase\dcomrem\resolver.cxx(2303)\combase.dll!00007FFEAB8999FD: (caller: 00007FFEAB8993F3) ReturnHr(1) tid(295c) 80040154 Class not registered
    onecore\com\combase\dcomrem\resolver.cxx(2389)\combase.dll!00007FFEAB899466: (caller: 00007FFEAB814459) ReturnHr(2) tid(295c) 80040154 Class not registered
    Exception thrown at 0x00007FFEAAD74FD9 in CGMetaData.exe: Microsoft C++ exception: long at memory location 0x0000006C48D6C850.
    Exception thrown at 0x00007FFEAAD74FD9 in CGMetaData.exe: Microsoft C++ exception: long at memory location 0x0000006C48D6C954.
    Exception thrown at 0x00007FFEAAD74FD9 in CGMetaData.exe: Microsoft C++ exception: long at memory location 0x0000006C48D6CA60.
    Exception thrown at 0x00007FFEAAD74FD9 in CGMetaData.exe: Microsoft C++ exception: _com_error at memory location 0x0000006C48D6D220.

    Have no idea what any of this means. Would appreciate any help.

  2. #2
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,279

    Re: Visual Studio Extracting Data from MSAccess Databases

    Perhaps, it is the problem with the DLL registering in win32/64bit systems?
    Like discussed here: https://stackoverflow.com/questions/...gistered-error
    Victor Nijegorodov

  3. #3
    Join Date
    Oct 1999
    Location
    ks
    Posts
    522

    Re: Visual Studio Extracting Data from MSAccess Databases

    As is virtually a near inviolate objective, MS apparently again has taken any and all actions necessary to invalidate any prior solutions. The suggested solutions direct one to:

    Solution: Go into the Project Properties, Compile tab and click "Advanced Compile Options...". Change "Target CPU" to x86, click OK, save and try again

    Very effective stopping me cold in my tracks as VS2022 displays no Compile tab when one goes to the Project Properties. The best I could do was to the Configuration Manager, then then the Active Solution Platform and change the setting from X64 to X86. However, attempting to build under that setting spawned errors such as:

    Severity Code Description Project File Line Suppression State
    Error (active) E0020 identifier "adCmdText" is undefined CGMetaData C:\cds\ClassLibrary\CAccessDBManager.cpp 128
    Error (active) E0020 identifier "adCmdText" is undefined CGMetaData C:\cds\ClassLibrary\CAccessDBManager.cpp 217
    Error (active) E0020 identifier "adLockOptimistic" is undefined CGMetaData C:\cds\ClassLibrary\CAccessDBManager.cpp 128

    I believe these are related to :

    #import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename("EOF", "ADOEOF")
    #include "comutil.h"
    #include "afxtempl.h"

    Suggestions??

  4. #4
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,279

    Re: Visual Studio Extracting Data from MSAccess Databases

    Try to add ADODB:: prefix like
    ADODB::adCmdText, ADODB::adLockOptimistic and so on.
    it is the fastest way to overcome this issue. (I used it with a success)
    Victor Nijegorodov

  5. #5
    Join Date
    Feb 2022
    Posts
    29

    Re: Visual Studio Extracting Data from MSAccess Databases

    I am using Access 2010 and VB 2012. I have created a database in Access 2010. I usually connect database to Visual Basic - Tools - Connect to Database. Is it right?

    After that, how to display the values of Access Database in Textbox or Labels?

    I tried doing this Accessname1 = TextBox1 but it didn't work.

    Please
    Help
    Last edited by existenceproduct; July 22nd, 2022 at 06:07 AM.

  6. #6
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,279

    Re: Visual Studio Extracting Data from MSAccess Databases

    Quote Originally Posted by existenceproduct View Post
    I am using Access 2010 and VB 2012. I have created a database in Access 2010. I usually connect database to Visual Basic - Tools - Connect to Database. Is it right?

    After that, how to display the values of Access Database in Textbox or Labels?

    I tried doing this Accessname1 = TextBox1 but it didn't work.

    Please
    Help
    I never worked with VB projects using the DB connections, so I cannot help you in that problem.

    And, BTW, this is a Visual C++ Programming forum, not a Visual Basic one.
    Victor Nijegorodov

  7. #7
    Join Date
    Oct 1999
    Location
    ks
    Posts
    522

    Re: Visual Studio Extracting Data from MSAccess Databases

    had to put this down for a while. am assuming you can imagine my distaste for
    changing code that has worked for 15 or so years but will look into this.

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