<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="VB" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
Dim objConnection As OleDbConnection
Dim objCmd As OleDbCommand
Dim strConnection As String
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Northwind.mdb"
objConnection = New OleDbConnection(strConnection)
objConnection.Open()
objCmd = New OleDbCommand()
objCmd.Connection = objConnection
objCmd.CommandText = "[Sales by Category]"
objCmd.CommandType = CommandType.StoredProcedure
dgSales.DataSource = objCmd.ExecuteReader(CommandBehavior.CloseConnection)
dgSales.DataBind()
End Sub
</script>
<html>
<body>
<h2>Using a stored procedure</h2>
<asp:datagrid id="dgSales" runat="server" />
</body>
</html>
|