ASP 101 - Active Server Pages 101 storedqueries.aspx
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script runat="server">
	Sub Page_Load(sender as Object, e as EventArgs)
		Dim myConnection As OleDbConnection
		Dim myCommand    As OleDbCommand
		Dim myParameter  As OleDbParameter
		Dim myDataReader As OleDbDataReader
		' Create connection and set connection string	
		myConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " _
			& "Data Source=" & Server.MapPath("storedqueries.mdb") & ";")
		' Create a new command object
		myCommand = New OleDbCommand()
		' Set the properties of the command so that it uses our
		' connection and knows the name of the stored query to run.
		myCommand.Connection = myConnection
		myCommand.CommandText = "GetNameInfoById"
		myCommand.CommandType = CommandType.StoredProcedure
		' Create our input parameter Id, tell it it's
		' and integer and set it's value
		myParameter = myCommand.CreateParameter()
		With myParameter
			.ParameterName = "Id"
			.Direction = ParameterDirection.Input
			.OleDbType = OleDbType.Integer
			.Value = 1
		End With
		' Add parameter to our command
		' Open the connection to the database
		' Execute our command and have it return a datareader.
		' We then pull the data we want out of that.
		' Could just as easily databind to a DataGrid or do
		' whatever else you want to do with your data.
		myDataReader = myCommand.ExecuteReader()
		' Sort of a pointless loop since there's only one
		' row, but you get the point.
		Do While myDataReader.Read()
			lblFirstName.Text = myDataReader.GetString(0)
			lblLastName.Text  = myDataReader.GetString(1)
		' Close our reader
		' Close our connection
	End Sub
<title>ASP.NET Stored Access Queries Sample</title>
<p>Ran the stored query: <strong>GetNameInfoById</strong>.</p>
<p>Passed it one parameter:<br />
<strong>Id</strong> = 1<br />
It returned a DataReader which I used to print out this name:
<asp:Label id="lblFirstName" runat="server" />
<asp:Label id="lblLastName" runat="server" />
<hr />
Click <a href="">here</a>
to read about and download the source code.