Microsoft KB Archive/318917

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

Article ID: 318917

Article Last Modified on 3/9/2006

-

APPLIES TO


 * Microsoft .NET Framework 1.1 Service Pack 1
 * Microsoft .NET Framework 1.1 Service Pack 1

-



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  attribute before you import the namespace for the ODBC .NET data provider. For example: <%@ CompilerOptions='/R:&quot;C:\Program Files\Microsoft.NET\Odbc.Net\Microsoft.data.odbc.dll&quot;' %>  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.



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

<div class="references_section">