This article was previously published under Q310084
This article has been archived. It is offered "as is" and will no longer be updated.
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
For a Microsoft Visual Basic .NET version of this article, see 309485. For a Microsoft Visual C# .NET version of this article, see 310083.
This article refers to the following Microsoft .NET Framework Class Library namespace:
When you create an OLE DB connection with the OLE DB managed provider in .NET, you cannot create connections to ODBC datasources. Because ODBC has its own Managed provider in .NET, you receive an error if you use the Microsoft OLE DB provider for ODBC drivers option in the Data Link Properties dialog box. Additionally, you must load ADO into the application because the data link creates an ADODB Connection object that is not compatible with the OLEDBConnection object. Therefore, you must create an ADODB Connection and assign its ConnectionString property to the ConnectionString property of the OLEDBConnection object for this to work correctly.
1. Start Microsoft Visual Studio .NET, and create a new Managed C++ Application project. Name it OledbDL.cpp.
Replace the default code in OledbDL.cpp with the following code:
It requires additional effort to use this method to create an ODBC connection because the data link creates a connection string that is specific to OLE DB and is not compatible with the ODBC managed provider. For this to work, you must parse the ADODB connection string for the relevant information such as the user ID, password, and data source. After you obtain this information, you can use it to create a connection string that is specific to ODBC. Keep in mind that the data link only uses ODBC data source names (DSNs); therefore, you cannot create a DSN-less connection through the data link.