ODBC Problems

  • Thread starter Thread starter Steve Bishop
  • Start date Start date
S

Steve Bishop

I'm trying to test my ODBC connection. I need to use ODBC because of the
application restrictions. As per Microsoft directions for the known ODBC
error, I created a bin folder in my application directory. I'm assuming
my application directory is where I have my .ASPX page, right? I'm
getting the error:
There can be only one 'page' directive. Help appreciated.

<%@ Page Language="VB" %>
<%@ import Namespace="System.Data" %>
<%@ CompilerOptions='/R:"C:\Program
Files\Microsoft.NET\Odbc.Net\Microsoft.data.odbc.dll"' %>
<%@ import Namespace="Microsoft.Data.ODBC" %>
<script runat="server">

Sub Page_Load(source As Object, E As EventArgs)

Dim cn as OdbcConnection
cn = New OdbcConnection
("dsn=SOTAMAS90AUTO;uid=TRY;pwd=Turux;")
Dim mystring As String = "Select * AR1_CustomerMaster"
Dim cmd As OdbcCommand = New OdbcCommand(mystring)
cn.Open()
MsgBox("Connected")
cn.Close()
End Sub

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<!-- Insert content here -->
</form>
</body>
</html>
 
CompilerOptions is Page directive attribute so you need to put it with
the Page directive. As the error message says you can't declare more
then one page directive on a page.

<%@ Page Language="VB" CompilerOptions='/R:"C:\Program
Files\Microsoft.NET\Odbc.Net\Microsoft.data.odbc.dll"'%>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="Microsoft.Data.ODBC" %>
<script runat="server">


HTH

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
 
Back
Top