dim email, password
Response.Buffer = true
Response.Clear
email = trim(Request("login"))
password = trim(Request("password"))
If email <> "" Then
dim objAccount
set objAccount = Server.CreateObject("FMStocks_Bus.Account")
dim AccountID, FullName
if objAccount.VerifyLogin(email, password, FullName, _
AccountID) then
Response.Cookies("Account")("AccountID") = AccountID
set objAccount = nothing
Response.Redirect("home.htm")
else
set objAccount = nothing
Response.Redirect("default.htm")
end if
else
Response.Redirect ("default.htm")
end if
Figure 4 Running a Stored Procedure
Public Function VerifyUser(ByVal email As String, _
ByVal password As String, _
ByRef AccountID As Variant, ByRef FullName As Variant) _
As Boolean
On Error GoTo errorHandler
Dim strUserInfo As String
'The following code was taken from Database.cls RunSPWithString
'and modified to support 2 outputs and 1 return value
' Set up Command and Connection objects
Dim cmd As ADODB.Command
Set cmd = CtxCreateObject("ADODB.Command")
'Run the procedure
cmd.ActiveConnection = GetDSN()
cmd.CommandText = "Account_VerifyLogin"
cmd.CommandType = adCmdStoredProc
With cmd
.Parameters.Append .CreateParameter(, adInteger, _
adParamReturnValue) 'rs(4).Value
.Parameters.Append .CreateParameter("@EMail", _
adVarChar, adParamInput, 50, email)
.Parameters.Append .CreateParameter("@Password", _
adVarChar, adParamInput, 50, password)
.Parameters.Append .CreateParameter("@AccountID", _
adInteger, adParamOutput, 4)
.Parameters.Append .CreateParameter("@FullName", _
adVarChar, adParamOutput, 50)
End With
cmd.Execute , , ADODB.adExecuteNoRecords
If cmd.Parameters(0).Value = 0 Then
VerifyUser = False
Else
AccountID = cmd.Parameters(3).Value
FullName = cmd.Parameters(4).Value
VerifyUser = True
End If
Set cmd = Nothing
CtxSetComplete
Exit Function
errorHandler:
RaiseError g_modName, "VerifyUser"
End Function
Figure 5 Disconnected Recordset
Function RunSPWithRS(ByVal strSP As String, _
ParamArray params() As Variant) As adodb.Recordset
On Error GoTo errorHandler
Dim rs As adodb.Recordset, cmd As adodb.Command
Set rs = CtxCreateObject("ADODB.Recordset")
Set cmd = CtxCreateObject("ADODB.Command")
'Run the procedure
cmd.ActiveConnection = GetDSN()
cmd.CommandText = strSP
cmd.CommandType = adCmdStoredProc
collectParams cmd, params
rs.CursorLocation = adUseClient
rs.Open cmd, , adOpenForwardOnly, adLockReadOnly
Set cmd.ActiveConnection = Nothing
Set cmd = Nothing
Set rs.ActiveConnection = Nothing
Set RunSPWithRS = rs
Exit Function
errorHandler:
RaiseError g_modName, "RunSPWithRS(" & strSP & ", ...)"
End Function
Figure 7 Accessing Recordset Data
%>
<table cellpadding=2 cellspacing=2 bordercolor=Gray bgcolor=White border=2 cols=2 rules=ALL>
<tr><td bgcolor=Gray align=Left width=50><Font face=Tahoma size=1 color=White><b>Ticker
<td bgcolor=Gray align=Left width=150><Font face=Tahoma size=1 color=White><b>Company
</tr>
<%
end if
do until rs.EOF
%>
<tr><td><a href="TickerDetail.asp?ticker=<%=fldTicker.value%>">
<%=fldTicker.value%></a><td><%=fldCompany.value%></tr>
<%
rs.MoveNext
loop
count = rs.RecordCount
rs.Close
set rs = nothing
%>
</table>
<%
end if
Response.Write "<p>" & count & " records found.<p>"
end if
end sub
%>