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.
Bug #: 398546 (SQLBUDT)
Caution ADO and ADO MD have not been fully tested in a Microsoft .NET Framework environment. They may cause intermittent issues, especially in service-based applications or in multithreaded applications. The techniques that are discussed in this article should only be used as a temporary measure during migration to ADO.NET. You should only use these techniques after you have conducted complete testing to make sure that there are no compatibility issues. Any issues that are caused by using ADO or ADO MD in this manner are unsupported. For more information, see the following article in the Microsoft Knowledge Base:
840667 You receive unexpected errors when using ADO and ADO MD in a .NET Framework application
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.
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.
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:
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=126.96.36.199, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A, processorArchitecture=MSIL The cache of ngen files contains the following entries: Number of items = 1
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.