Problem using #import with ADODB in VS2005

I have a VS2003 project that I am migrating to VS2005. It currently compiles just fine under VS2003, but when I try to compile it under VS2005, I get a whole slew of C2327 errors. The root cause appears to be the different way that VS2005 handles nested classes.

However, the code that the compiler is having a problem with is generated by VS itself as a result of a #import:

#import "C:\Program Files\Common Files\System\ado\msado25.tlb" rename("EOF", "adoEOF") rename("BOF", "adoBOF") rename_namespace("ADODB")

An example of the error that I receive is:

error C2327: 'ADODB::_ADO::Properties' : is not a type name, static, or enumerator

Has anyone else encountered this sort of thing Any ideas on a work-around

Any assistance would be welcome. Thanks in advance.

David Mullin
IMA Technologies



Answer this question

Problem using #import with ADODB in VS2005

  • Hayd3n

    it didnt work...

  • akoties

    Thanks Ted.

    In fact, David's solution also works for me. I did not realize it as I misunderstood which file is compiled firstly.

    Now, the project could be compiled without error, after I put the import lines into the very beginning of stdafx.h :)

    Thanks everyone, again:)


  • Ananda Ganesh

    well, i have exactly the same problem since today :) - if u find a solution - please post it here....

    thanx


  • Erling Ervik

    Robert and David,

    I meet the same problem with Robert, could you give me a little more hint

    Thanks


  • NickNotYet

    I did get a final resolution from MS. The "resolution" is that it is a bug in Visual Studio that they will address at some point in the future (probably not until Orca).

    But, at least the work-around actually seems to work.

    David Mullin


  • Harry_Leboeuf

    Carol, in future, please post at bottom (i.e. reply to the final reply), as the Microsoft forum software is messed up and likes to put replies in the middle, making new posts difficult to track down for long threads. 

    If David's solution did not work above (it should work), I believe this problem can sometimes be solved by using Start - Search - files and folders, then finding and deleting all TLH and TLI files from the folder (and all subfolders) where your project files are located.  I have found in the past that even a clean and rebuild all does not always delete old TLH and TLI files. 

     


  • gnanforu

    David,

    Thanks for the hints. I have the same problem, but my code does not have the line "include msado15.h". Could you please give more specifics about your workaround solution.

    Thanks.


  • Rashar

    Perhaps you need to do a Clean followed by a Rebuild-All. That would help remove any remaining 2003 generated files.

  • Jehan Badshah

    I have made some progress. It turns out that if you have included msado15.h before your #import, then the files generated by the #import are different and do not compile. The workaround I'm currently using is to add a dummy file to my project (named to ensure that it is the first file to be compiled) that just has the #import in it, with no other includes (other than stdafx.h). This generates the tlh/tli files correctly, and then the rest of the compilation proceeds without error.

    I'm also working with MS for a real solution. I'll post it here if I get one.

    David Mullin


  • mamo

    I tried the exact same thing in a wizard generated MFC project and instantiated something, so a TLH and TLI file would be created, and I had no compilation errors. Try this out and see if you have any problems.

    Can you provide some more information about your project i.e. what are you including before and after the #import, what the exact errors are with line numbers, etc. The preprocessor may be causing some problems in your app.


  • Problem using #import with ADODB in VS2005