The differences between the development environment of VC compilation ADO and the customer environment may cause failures.

Source: Internet
Author: User
· Target audience of this announcement board should be read:Target customers who apply Microsoft ADO 2.5 and later versions. This includes VC programmers who use Microsoft Windows XP, SQL Server 2000, and MDAC 2.7. · Potential impact of weak links:The application compiled by VC fails to run. · Symptom:Compile the following code on the development machine: # pragma warning (push) // Needs to be done in order to suppress warning message
# Pragma warning (disable: 4146) // caused by bug in ADO (MS Knowledge Base article Q253317)
# Import "C:/Program Files/Common Files/system/ado/msado15.dll "/
No_namespace rename ("EOF", "adoEOF ")
# Pragma warning (pop)... _ CommandPtr pCmd = NULL;
HRESULT hr = pCmd. createInstance ("ADODB. command "), but an error occurs on the customer's normal Windows2000: Command pointer creation failed, error code: 0x80004002, error Description: no such interface. · Cause:Mdac2.7 is usually installed on our development machine, which may be caused by the installation of SQL Server or WINXP. The customer machine only has mdac2.5. Microsoft's ADO development team is used to naming the latest version of ADO as the default Interface. For example, in ado2.5, _ command25 is named as _ command. In this way, when you compile the VC code in mdac2.7, The interfaceid of the bound _ command may be the interface ID of _ command2.7. In the customer's mdac2.5 environment, this interface ID may not exist. Its _ command interface ID is still 2.5, which is definitely different from the _ command interface ID on your machine. Therefore, the _ commandptr pointer cannot be created in VC mode. However, because VB is not bound to interfaceid, you can also create an ADO interface pointer in VB. · Solution:First, it is compiled only in the mdac2.5 environment and released to the customer environment above mdac2.5, but windxp cannot; Second: force the customer environment to upgrade MDAC; Third: compile in the mdac2.7 environment, but we only explicitly create the command25 pointer, as shown below: ADODB :: Command25ptrPcmdchange = NULL;
Hresult = pcmdchange. createinstance (_ uuidof (ADODB: Command); 4: Select oledb; ========================================================== ==== · Reference 1:Please refer to this document and they complain very clearly: http://groups.google.com/groups? Q = b08400bd + command & HL = ZH-CN & LR = & Ie = UTF-8 & OE = UTF-8 & selm = uwaoaxd7bha. 1864% 40tkmsftngp04 & rnum = 1> the call to createinstance will fail when the code is
> Compiled with a MDAC 2.7 version of msado. dll but run on
> A system with MDAC 2.5 installed. It returns a HRESULT
> 0x80004002 (E_NOINTERFACE)-"The QueryInterface method
> Did not recognize the requested interface. The interface
> Is not supported. ". I. e. the code tried to find the new
> _ Command interface NOT the old _ Command interface
> Defined in MDAC 2.5.
> The code works fine when compiled with MDAC 2.5 and run
> On a system with MDAC 2.5 or greater. (Will also work
> Fine when compiled with MDAC 2.7 and run on MDAC 2.7 ).
>
> SOLUTIONS
> ------------------
>
> 1) Compile only on MDAC 2.5 and then can target MDAC 2.5
> Or greater (Not really an option with Windows XP (. NET
> Etc .))
>
> 2) Compile with MDAC 2.7 and force all clients to upgrade
> To MDAC 2.7 (Not an ideal solution as already have enough
> Problems when forcing clients to install MDAC 2.5-
> Breaking existing apps-or simply not installing
> Properly as part of the install process)
>
> 3) The solution we have come up with is to develop on
> Systems with MDAC 2.7 installed but not to use
> The "_ Command" interface. Instead we use the "Command25"
> Interface (I. e. this is the renamed "_ Command" interface
> From MDAC 2.5). This means all our developers are forced
> To develop on MDAC 2.7 but we can continue to target MDAC
> 2.5 or better). I. e. the above code becomes
>
> ADODB: command25ptr pcmdchange = NULL;
> Hresult = pcmdchange. createinstance
> (_ Uuidof (ADODB :: Command));

==================================· Reference 2:Another Chinese Reference: My ATL/ADO programming twists and turns horris (original) http://www.csdn.net/develop/article/14/14662.shtm

Trackback: http://tb.blog.csdn.net/TrackBack.aspx? Postid = 12706

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.