You may receive an error message when you use the ODBC .NET data provider in WebForm applications (318917)



The information in this article applies to:

  • Microsoft ADO.NET (included with the .NET Framework)
  • Microsoft ASP.NET (included with the .NET Framework)

This article was previously published under Q318917

SYMPTOMS

When you use the ODBC .NET data provider in an ASP.NET page, you may receive one of the following error messages:
Type 'OdbcConnection' is not defined.

-or-

File or assembly name System.Data.Odbc, or one of its dependencies, was not found.

-or-

Namespace or type 'ODBC' for the Imports 'Microsoft.Data.ODBC' cannot be found

RESOLUTION

To work around this problem, use one of the following methods:
  • Include the <CompilerOptions> attribute before you import the namespace for the ODBC .NET data provider. For example:
    <%@ CompilerOptions='/R:"C:\Program Files\Microsoft.NET\Odbc.Net\Microsoft.data.odbc.dll"' %>
    					
  • Create a folder that is named bin in your application directory, and then paste the Microsoft.Data.ODBC.dll file into the bin folder.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Start Notepad, and then paste the following code:
    <%@ Import Namespace = "System.Data" %>
    <%@ Import Namespace = "Microsoft.Data.Odbc" %>
    <%
    Dim objConn As OdbcConnection
    %>
    					
  2. Save the file as OdbcCon.aspx in the C:\Inetpub\wwwroot directory.
  3. Open the OdbcCon.aspx page in your browser. Notice that you receive an error message.
  4. To work around this problem, copy and paste the <CompilerOptions> attribute code before you import namespaces for the Microsoft.Data.Odbc namespace:
    <%@ CompilerOptions='/R:"C:\Program Files\Microsoft.NET\Odbc.Net\Microsoft.data.odbc.dll"' %>
    <%@ Import Namespace = "Microsoft.Data.Odbc" %>
    					

REFERENCES

For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

313480 INFO: Roadmap for .NET Data Providers


Modification Type:MinorLast Reviewed:3/9/2006
Keywords:kbManaged kbprb kbSystemData KB318917