Debby Quock
9/26/2002 4:22:00 PM
Has anyone has problems or success with using ODBC.NET
with ASP.NET? I successfully installed ODBC.NET, and
checked that the namespace "Microsoft.Data.Odbc" did
indeed make its way into the global assembly cache (by
using the Visual Studio.NET gacutil.exe at the command
prompt). When I run the aspx file below from Internet
Explorer, I get the error message that "OdbcConnection
type is not defined", and also "Microsoft.Data.Odbc"
cannot be found during the import statement. I am not
sure why the aspx compiler cannot see the namespace
Microsoft.Data.Odbc. Is there other code that must be
included in the aspx file to be able to use ODBC.NET?
Thanks for all and and help,
Debby
-->
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="Microsoft.Data.Odbc" %>
<%@ Page aspcompat=true Language=VB Debug=true %>
<HTML>
<HEAD>
<TITLE>ACS034 - ASP.NET Database Connection
Test</TITLE>
</HEAD>
<Script Language=VB Runat=Server>
Sub Page_Load(Sender As Object, e As EventArgs)
dim MyConnection As OdbcConnection
dim MyCommand As OdbcDataAdapter
dim MyDataset As DataSet
dim MyTable As DataTable
dim loop1, numrows As Integer
dim sqlstr As String
sqlstr = "SELECT BPM.DEVICE_NAME FROM BPM"
'Create a connection to the data source...
MyConnection = New OdbcConnection
("DSN=XXXXX;UID=xxxxxxxx;PWD=xxxxxxxx")
MyConnection.Open()
Response.Write("<p>Connection to ATLAS5
Opened...")
MyCommand = New OdbcDataAdapter(sqlstr,
MyConnection)
Response.Write("<p> Retrieve Oracle Rdb
Table BPM records...<p>")
'Fill a DataSet with data returned from the
database...
MyDataset = New DataSet
MyCommand.Fill(MyDataset)
MyTable = New DataTable
MyTable = MyDataset.Tables(0)
MyConnection.Close
Response.Write("<p>Connection to ATLAS5
Closed")
End Sub
</Script>
</HTML>