CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14
  1. #1
    Join Date
    Apr 2013
    Location
    Prague / Cracow
    Posts
    47

    Jet OLEDB:Engine on Windows7 (64bit) - Compact Access Database problem

    Hey ho!

    I'm using ADO in my WINAPI project with Microsoft.ACE.OLEDB.12 (msado26.tlb) with no problem, but now I need to be able to compact the database from my application and i've learnt that to do so i need to add msjro.dll to my project to execute the following code:

    Code:
    void db_compact()
    {
    	try
    {
       IJetEnginePtr jet(__uuidof(JetEngine));
      jet->CompactDatabase( "Provider=Microsoft.Jet.OLEDB.12.0;Data Source=d:\\xxx.accdb;Jet OLEDB:Database Password=test", 
    "Provider=Microsoft.Jet.OLEDB.12.0;Data Source=d:\\xxx.accdb;" 
    "Jet OLEDB:Engine Type=5;Jet OLEDB:Database Password=test");
    }
    catch(_com_error e) 
    {       
      errorhandler(e);  
    }
    	
    }
    IJetEnginePtr and JetEngine are properly recognized as classes in my Visual Studio but the problems is that when i try to import the JET dll itself by:
    Code:
    #import "C:\Program Files (x86)\Common Files\System\ado\msjro.dll" no_namespace
    my compiler gives the following errors:
    2 <path>\msjro.tlh IntelliSense: identifier "_Recordset_DeprecatedPtr" is undefined 196
    3 <path>\msjro.tlh IntelliSense: identifier "_Recordset_DeprecatedPtr" is undefined 224
    4 <path>\msjro.tlh error C2146: syntax error : missing ';' before identifier 'ConflictTables' 196
    5 <path>\msjro.tlh error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 196
    6 <path>\msjro.tlh error C2146: syntax error : missing ';' before identifier 'GetConflictTables' 224
    7 <path>\msjro.tlh error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 224
    8 <path>\msjro.tlh warning C4183: 'GetConflictTables': missing return type; assumed to be a member function returning 'int' 224
    1 <path>\msjro.tli IntelliSense: identifier "_Recordset_DeprecatedPtr" is undefined 111
    9 <path>\msjro.tli error C2143: syntax error : missing ';' before 'IReplica::GetConflictTables' 111
    10 <path>\msjro.tli error C2433: '_RecordsetPtr' : 'inline' not permitted on data declarations 111
    11 <path>\msjro.tli error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 111
    12 <path>\msjro.tli error C2064: term does not evaluate to a function taking 2 arguments 115
    I cannot find any threat that gives some resolution to this problem which (from what i've read) apparently appears on WIN7 64 bit only (my OS!) although the application i compile is a WIN32.

    Has anyone heard about any solution for this? From what i've read on other forums the JET does not go together with 64 Win7 but somehowe I have it installed. Only my compilator doesn't understand those certain parts of msjro.tlh and .tli... while importing that msjro.dll. I am a bit lost... :-0

    will be grateful for any hint!

    cheers
    b.
    Last edited by berkov; June 20th, 2013 at 12:46 AM.

  2. #2
    Join Date
    Apr 2013
    Location
    Prague / Cracow
    Posts
    47

    Re: Jet OLEDB:Engine on Windows7 (64bit) - Compact Access Database problem

    OK.. seems i have found it.
    for win7 64 i need to also use msado60.tlb, so i commented my previous msado26.tlb and used msado60.tlb with msjro.dll instead, like this:

    Code:
    //#import "C:\Program Files\Common Files\System\ado\msado26.tlb" rename( "EOF", "ADOEOF" )
    #import "C:\Program Files (x86)\Common Files\System\ado\msado60.tlb" rename( "EOF", "ADOEOF" )
    #import "C:\Program Files (x86)\Common Files\System\ado\msjro.dll" no_namespace
    but now, i'm getting following error.
    when on runtime i call for my function db_compact() i get from my errorhandler(e) function the following MessageBox:
    "Class not registered" (which is e.Description())
    - 2147221164 (which is e.Error())
    "Class not registered" (which is e.ErrorMessage())

    Any ideas why?

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Jet OLEDB:Engine on Windows7 (64bit) - Compact Access Database problem

    Did you google?
    For example, thid discussion: http://www.vbforums.com/showthread.p...stered-problem
    Victor Nijegorodov

  4. #4
    Join Date
    Apr 2013
    Location
    Prague / Cracow
    Posts
    47

    Re: Jet OLEDB:Engine on Windows7 (64bit) - Compact Access Database problem

    Quote Originally Posted by VictorN View Post
    Did you google?
    For example, thid discussion: http://www.vbforums.com/showthread.p...stered-problem
    your link does not really seem to be my case.

    yep, i've searched the internet and have not really found anything useful.
    in most of the threats it says something like:
    "Jet OLEDB is depricated and is not installed with operating system since MDAC 2.6 (might be 2.5). Anyway, you need to use new ACE OLEDB provider instead of Jet in your applications and install it on target PC where application should run. "
    but i cannot use ACE coz it does not contain IJetEnginePtr which i need to compact my database. this all is so confusing to me.

    to make it confusing even more, when i tried to compile the same code on my company PC (also win7 and 64 bit) i got exactly the same problems as described in my original post and could not even compile it!

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Jet OLEDB:Engine on Windows7 (64bit) - Compact Access Database problem

    Well, in this link there is information that unistalling of IE10 (if it was installed) might help.
    Victor Nijegorodov

  6. #6
    Join Date
    Apr 2013
    Location
    Prague / Cracow
    Posts
    47

    Re: Jet OLEDB:Engine on Windows7 (64bit) - Compact Access Database problem

    Quote Originally Posted by VictorN View Post
    Well, in this link there is information that unistalling of IE10 (if it was installed) might help.
    i am using IE8 - and i don't really think it might be anyhow connected.

  7. #7
    Join Date
    Apr 2013
    Location
    Prague / Cracow
    Posts
    47

    Re: Jet OLEDB:Engine on Windows7 (64bit) - Compact Access Database problem

    Hey ho.. got a bit closer...
    I'm using JET (not ACE) and it seems that the highest version in JET is 4 (not 12), so my string should look like this:

    CompactDatabase( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\xxx.accdb;Jet OLEDB: Database Password=test",
    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\xxx.accdb;"
    "Jet OLEDB:Engine Type=5;Jet OLEDB: Database Password=test");


    Now i'm getting the following error:
    2147467259
    Unrecognized database format.

    Is there any way i can make my CompactDatabase work with new accdb? Have they really stopped supporting it?
    will keep searching....

  8. #8
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Jet OLEDB:Engine on Windows7 (64bit) - Compact Access Database problem

    Quote Originally Posted by berkov View Post
    Hey ho.. got a bit closer...
    I'm using JET (not ACE) and it seems that the highest version in JET is 4 (not 12)...
    AFAIK JET does not work with .accdb files. It is only for .mdb. Thus you got this "Unrecognized database format" error.
    You might want also to read this discussion: http://stackoverflow.com/questions/1...se-by-net-code
    Victor Nijegorodov

  9. #9
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Jet OLEDB:Engine on Windows7 (64bit) - Compact Access Database problem

    you cannot load a 32bit COM dll (msjro.dll) from a 64bit application.

  10. #10
    Join Date
    Aug 2018
    Posts
    2

    Question Re: Jet OLEDB:Engine on Windows7 (64bit) - Compact Access Database problem

    I am trying to do the same on windows 10 (64 bit) in VC++ on VS 2017.
    I am getting an error called CLASS_NOT_REGISTERED while creating an instance of IJetEnginePtr.
    Is msjro.dll available in 64 bit?
    If not, what else can be done in order to compact the database (.mdb file) in vc++ application?

  11. #11
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Jet OLEDB:Engine on Windows7 (64bit) - Compact Access Database problem

    Try installing the 64 bit access driver. https://www.microsoft.com/en-us/down....aspx?id=13255

    Use the Microsoft.Jet.OLEDB.4.0 provider to do the compaction. This is the jet docs from sql server wh8ch references Access compaction: https://docs.microsoft.com/en-us/sql...ql-server-2017

  12. #12
    Join Date
    Aug 2018
    Posts
    2

    Question Re: Jet OLEDB:Engine on Windows10 (64bit) - Compact Access Database problem

    Thank you Arjay!!
    I am working with 64 bit VC++ application using ACE OLEDB on Windows 10 (64 bit).
    I have installed 64 bit ACE 2016 and using provider Microsoft.ACE.OLEDB.12.0.
    How can I compact the database in this scenario?
    I cannot use DBPROP_JETOLEDB_COMPACTFREESPACESIZE with ACE OLEDB.
    Please comment.

  13. #13
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Jet OLEDB:Engine on Windows7 (64bit) - Compact Access Database problem

    I have the 64 access driver installed on my machine. I searched the registry HKCR/CLSID for Microsoft.Jet.OLEDB.4.0. This gave me the guid of HKEY_CLASSES_ROOT\WOW6432Node\CLSID\{dee35070-506b-11cf-b1aa-00aa00b8de95}

    Searching for the guid, gave me an InprocServer32 of C:\Windows\SysWOW64\msjetoledb40.dll

    Try doing the import of this dll.

    #import "C:\Windows\SysWOW64\msjetoledb40.dll" no_namespace

    The SysWOW64 folder contains 32 bit binaries, so this still may not work.

  14. #14
    Join Date
    Sep 2018
    Posts
    9

    Re: Jet OLEDB:Engine on Windows7 (64bit) - Compact Access Database problem

    Thank you for providing best solution. My problem is sorted out.

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