<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Data.OleDb" %>
<%@ Page debug="true" %>
<html>
<head>
<title>Connecting to an Access Database</title>
</head>
<body>
<H3>Connecting to an Access Database</H3>
<asp:DataGrid id="dgSuppliers" runat="server" />
</body>
</html>
<script language="VB" runat="server">
Sub Page_Load(Source As Object, E As EventArgs)
Dim strConnection As String = "Provider=Microsoft.Jet.OleDb.4.0;" & _
"data source=C:\northwind.mdb;"
Dim objConnection As New OleDbConnection(strConnection)
Dim strSQL As String = "SELECT SupplierID, CompanyName " & _
"FROM Suppliers;"
Dim objCommand As New OleDbCommand(strSQL, objConnection)
objConnection.Open()
dgSuppliers.DataSource = objCommand.ExecuteReader()
dgSuppliers.DataBind()
objConnection.Close()
End Sub
</script>