This example illustrates the usage of parameters in asp.net with MS Access. It’s a simple sub that takes one parameter, first name, and print the Last name on the page.
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
Sub Print_Last_Name (First_Name as string)
Dim conn As OleDbConnection
Dim strLastName As String
Dim cmd As OleDbCommand
conn = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=c:\users.mdb" )
strLastName = "Select LastName From users Where FirstName=? "
cmd = New OleDbCommand( strLastName, conn )
cmd.Parameters.Add( "@firstname", First_Name )
conn.Open ()
Response.write ("Home Phone Is " & cmd. ExecuteScalar ()
conn.Close ()
End Sub



