<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script runat="server">
'declare connection
dim Conn as new OleDbConnection( _
"PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
& "DATA SOURCE=" _
& Server.MapPath("EmployeeDatabase.mdb;"))
sub Submit(Sender as Object, e as EventArgs)
dim objCmd as OleDbCommand = new OleDbCommand("SelectIDFromName", Conn)
dim objReader as OleDbDataReader
objCmd.CommandType = CommandType.StoredProcedure
dim objParam as OleDbParameter
objParam = objCmd.Parameters.Add("@FirstName", OleDbType.Char)
objParam.Direction = ParameterDirection.Input
objParam.Value = tbFirst.Text
objParam = objCmd.Parameters.Add("@LastName",OleDbType.Char)
objParam.Direction = ParameterDirection.Input
objParam.Value = tbLast.Text
try
objCmd.Connection.Open()
objReader = objCmd.ExecuteReader
catch ex as OleDbException
Response.Write("Error retrieving data.")
end try
DataGrid1.DataSource = objReader
DataGrid1.DataBind()
objCmd.Connection.Close()
End Sub
</script>
<html><body>
<form runat="server">
Enter a first name:
<asp:TextBox id="tbFirst" runat="server"/><br>
Enter a last name:
<asp:TextBox id="tbLast" runat="server"/>
<asp:Button id="btSubmit" runat="server"
Text="Submit"
OnClick="Submit"/>
<asp:DataGrid id="DataGrid1" runat="server"
AutoGenerateColumns="true" />
</form>
</body></html>
|