CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2010
    Posts
    8

    Confusion with #import and msado

    Hi,

    I have been exploring msado for connecting to an MS SQL server and built a project around it. I am a bit confused though, here's why.

    I have a line:

    #import "msado60.tlb" no_namespace rename("EOF", "ADOEndOfFile")

    Originally I had used msado15.dll but upon further reading I thought maybe that was old and I should update to the 60 version. So this is where my confusion lies. Let's assume I want this to run on Windows XP as well as Windows Server 2008. I am assuming the msado15.dll is the interface that works behind the scenes and by specifying msado60.tlb I am using a newer set of functions built into the DLL? Is this correct?

    Also, if I think of this as "using the latest version of the library available", am I doing it right? Would the app when installed on XP use the 60 interface or default back to an earlier one that it understands, and do newer OS's like Server 2012 use a later version of the interface just by virtue of having it run in that environment?

    Or am I completely out to lunch here and have no idea what I'm talking about?

    Thanks!

  2. #2
    Join Date
    May 2004
    Location
    45,000FT Above Nevada
    Posts
    1,539

    Re: Confusion with #import and msado

    Quote Originally Posted by Whargod View Post
    Hi,

    I have been exploring msado for connecting to an MS SQL server and built a project around it. I am a bit confused though, here's why.

    I have a line:

    #import "msado60.tlb" no_namespace rename("EOF", "ADOEndOfFile")

    Originally I had used msado15.dll but upon further reading I thought maybe that was old and I should update to the 60 version. So this is where my confusion lies. Let's assume I want this to run on Windows XP as well as Windows Server 2008. I am assuming the msado15.dll is the interface that works behind the scenes and by specifying msado60.tlb I am using a newer set of functions built into the DLL? Is this correct?

    Also, if I think of this as "using the latest version of the library available", am I doing it right? Would the app when installed on XP use the 60 interface or default back to an earlier one that it understands, and do newer OS's like Server 2012 use a later version of the interface just by virtue of having it run in that environment?

    Or am I completely out to lunch here and have no idea what I'm talking about?

    Thanks!


    this works in VS2010 on SQL Server 2005, 2008
    Code:
    #import "C:/YourProgDir/msado60_Backcompat_i386.tlb" no_namespace rename( "EOF", "adoEOF" )
    Jim
    ATP BE400 CE500 (C550B-SPW) CE560XL MU300 CFI CFII

    "The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.

    "Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.

  3. #3
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Confusion with #import and msado

    Quote Originally Posted by Whargod View Post
    Originally I had used msado15.dll but upon further reading I thought maybe that was old and I should update to the 60 version. So this is where my confusion lies. Let's assume I want this to run on Windows XP as well as Windows Server 2008. I am assuming the msado15.dll is the interface that works behind the scenes and by specifying msado60.tlb I am using a newer set of functions built into the DLL? Is this correct?
    You evidently miss a couple of important things here. First thing is what #import really does. Importing COM server, or TLB, in fact creates a C/C++ header file that provides your other source code with GUIDs and COM interface declarations, as well as enumerations and other types the server interfaces depends on. So in terms of awareness of "newer set of functions" you are correct. But the real question is whether you are really going to use those?

    Second thing about COM you need to understand is immutability of interfaces ever published in the past. The "newer set of functions" is always built on top of the previous set. Therefore, in case your code makes use of interfaces limited to the original subset, your code is going to work with any version of the COM server supporting the subset. This means that both cases possible:
    • you build your code with msado15 imported and able to run it in Windows 7/8
    • you build your code with msado60 imported and able to run it in Windows XP


    Also, if I think of this as "using the latest version of the library available", am I doing it right? Would the app when installed on XP use the 60 interface or default back to an earlier one that it understands, and do newer OS's like Server 2012 use a later version of the interface just by virtue of having it run in that environment?

    Or am I completely out to lunch here and have no idea what I'm talking about?
    Another thing to understand is COM server implementation and deployment. When COM server appears released for particular product, it is registered with corresponding values in registry. In your case msado15 is registered as a part of SQL Server Express that goes with XP. Any other SQL Server installer may install another version of msado into the system along with the new SQL Server engine. Now the two msado versions coexist in the system. But this does not mean the basic connectivity is not going to work with the new SQL Server version.

    Likewise, an application built to work with SQL Server Express in XP is going to work just fine with SQL Server Express in Windows 7 despite the fact that Windows 7 has greater version of Express. What COM server version to load is defined by server CLSID particular registration details, while application knows CLSID only.
    Best regards,
    Igor

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