Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

You may receive an "ADODB.Connection is not defined" error message when you try to create a new instance of an ADO connection in an ASP.NET-based application


View products that this article applies to.

Symptoms

When you use a Microsoft ActiveX Data Objects (ADO) object in a Microsoft ASP.NET-based application to connect to a Microsoft SQL Server database, you may receive the following error message:
Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30002: Type 'ADODB.Connection' is not defined.
For example, this problem occurs when you create a new instance of an ADODB.Connection object or an ADODB.Recordset object. This problem also occurs when you pass a variable of type ADODB to a function.

Note In Visual Studio 2005, when you add a reference to the ADODB Primary Interop Assembly (PIA), Visual Studio 2005 automatically updates the Web.config file to insert the reference to the ADODB PIA. Therefore, this problem will not occur.

↑ Back to the top


Cause

This problem may occur if the application does not explicitly reference the ADODB PIA. You must explicitly reference the ADODB PIA in the Web.config file so that the ASP.NET-based application can correctly compile the .aspx pages.

↑ Back to the top


Workaround

To work around this problem, you can modify the Web.config file for the server or you can modify the local copy of the Web.config file that is in the virtual directory where the .aspx pages are located.

To modify the Web.config file, follow these steps:
  1. Use the Global Assembly Cache tool (GacUtil.exe) to locate the global assembly cache (GAC) assembly registration for the ADODB PIA. To do this, run the following command at a command prompt:
    gacutil.exe /l adodb
    At the command prompt, you receive output that is similar to the following:
    The Global Assembly Cache contains the following assemblies:
    ADODB, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A, processorArchitecture=MSIL
    The cache of ngen files contains the following entries:
    Number of items = 1
  2. In the Web.config file, use the following code sample to add a reference to the ADODB PIA. In the code sample, replace the assembly details with the assembly details that you obtained in step 1.
    <configuration>
    <system.web>
    <compilation>
    <assemblies>
    <add assembly="ADODB, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A, processorArchitecture=MSIL"/>
    </assemblies>
    </compilation>
    </system.web>
    </configuration>
    
  3. Save the Web.config file.
  4. Restart the Microsoft Internet Information Services (IIS) service. To do this, run the following command at the command prompt:
    iisreset

↑ Back to the top


Properties

Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.

↑ Back to the top


Keywords: KB907742, kbprb, kbtshoot

↑ Back to the top

Article Info
Article ID : 907742
Revision : 3
Created on : 11/28/2007
Published on : 11/28/2007
Exists online : False
Views : 582