Viewing source for Recipe1005vb.aspx
<%@ Page Language="VB" %>
<%@ Import Namespace="Microsoft.Data.Odbc" %>
<script runat="server">
Sub Page_Load (sender As Object, e As EventArgs)
'get connection string from dropdown list
Dim connectString As [String] = "DSN=myDSN;Uid=user;Pwd=pass"
Dim myConn As OdbcConnection = Nothing
'use try/catch because we may fail to connect
Try
myConn = New OdbcConnection(connectString)
myConn.Open()
'we connected!
lblConnectInfo.Text = "Connection successful!"
Catch
'was your connection string correct?
lblConnectInfo.Text = "Connection failed!"
Finally
If Not myConn Is Nothing Then
myConn.Close()
End If
End Try
End Sub
</script>
<html>
<head>
<title>Recipe1004vb</title>
</head>
<body>
<form id="Recipe1004vbForm" method="post" runat="server">
This page simply tries (and fails) to open an ODBC connection.
<asp:Label id="lblConnectInfo" runat="server"></asp:Label>
</form>
</body>
</html>