Thanks for the response. I truly appreciate it. I used the if fuction for getting the session state and it returned "Connection successful". And I see that I have declared rstStoredProcedure as my recordset. But It's still telling me that the object rstStoredProcedure is closed when I try to display it. Here is the entire code with all the changes highlighted. What could be wrong?
<%
dim dataConn, adocmd, IsValid
Set rstStoredProc = Server.CreateObject("ADODB.Recordset")
dataConn.Open "Provider=sqloledb;Data Source=REMITCOCLTVOL;Initial Catalog=REMITCOSQLServer;Integrated Security=SSPI;"
Set adocmd = Server.CreateObject("ADODB.Command")
adocmd.CommandText = "sp_IsValidLogon"
adocmd.ActiveConnection = dataConn
adocmd.CommandType = adCmdStoredProc
adocmd.Parameters.Append adocmd.CreateParameter("return", _
adInteger, adParamReturnValue, 3)
adocmd.Parameters.Append adocmd.CreateParameter("username", _
adVarChar, adParamInput, 16, _
Request.Form("UserName"))
adocmd.Parameters.Append adocmd.CreateParameter("password", _
adVarChar, adParamInput, 16, _
Request.Form("Password"))
adocmd.Execute
' Run the SP by executing the command and grab
' the returned recordset.
Set rstStoredProc = adocmd.Execute
rstStoredProc.CursorLocation = adUseClient
rstStoredProc.Open adocmd, , adOpenForwardOnly, adLockReadOnly, adCmdStoredProc
Trouble Spot
while not rstStoredProc.eof
' Message so people know what the sample's doing:
Response.Write "<p>It returned a recordset which I used " _
& "to print out this name: <strong>"
' Spit out our data which I pull out of the recordset.
'Response.Write Trim(rstStoredProc("Supervisors"))
Response.Write " "
'Response.Write Trim(rstStoredProc("Password"))
If dataConn.State = adStateOpen Then
Response.Write " Connection succesfull"
Else
Response.Write " Connection failed"
End If
' Message so people know what the sample's doing:
Response.Write "</strong>.</p>" & vbCrLf
rstStoredProc.movenext
wend
' Kill our objects
Set paramId = Nothing
Set rstStoredProc = Nothing
Set adocmd = Nothing
' Close and kill our connection
Set dataConn = Nothing
can you remove the line
Set rstStoredProc = adocmd.Execute
Well, I commented out the line Set rstStoredProc = adocmd.Execute and it's still telling me that the rstStoredPorc is closed. I've never seen anything like this. If I comment out "while not rstStoredProc.eof" the page runs just fine. Maybe if I gave the fields to my table it might help. The Stored Procedure is below as well. It's used to check logons against what's in the database. If some trys to hack into the site using another member's name without the password it will deactivate the account after 4 attempts. All this is working fine I just can't display a recordset. Any thoughts?
Table StarAdmin Field Names and Datatypes
RecordID int 4
Supervisors nvarchar 16
Password nvarchar 16
address nvarchar 150
SiteName nvarchar 80
Areas nvarchar 50
PTONames nvarchar 100
TeamLeaders nvarchar 50
Region nvarchar 150
UserType nvarchar 150
City nvarchar 150
Stat nvarchar 150
Zipcode nvarchar 150
Active numeric 9
Stored Procedure sp_IsValidLogon
CREATE PROCEDURE [dbo].[sp_IsValidLogon]
@UserName varchar (16),
@Password varchar (16)
As
if exists(Select * From StarAdmin
Where Supervisors = @UserName
And
Password = @Password
And
Active = 1)
begin
return(1)
end
else
begin
INSERT INTO FailedLogins(Supervisors, Password)
values(@UserName, @Password)
declare @totalFails int
Select @totalFails = Count(*) From FailedLogins
Where Supervisors = @UserName
And dtFailed > GetDate()-1
if (@totalFails > 5)
UPDATE StarAdmin Set Active = 0
Where Supervisors = @UserName
return(0)
end
GO
I must admint, this is wuppin my tail.
Simply because there is no recordset in sp_IsValidLogon, just a return code.
You want to capture the exit code?
Will capturing the exit code allow me to response.write out the results? I'd love to be able to do that.
Got puzzled again.
Do you wish to capture 1/0 (the exit code)
or the number of failed attempts?
I'm back. The first point is what I want. (the exit code) How do I capture it and print it out?
Welcome back.
Try the sample at http://support.microsoft.com/kb/q194792/.
Apparently there must be a recordset in order to capture the returncode.
Viewing 15 posts - 1 through 15 (of 15 total)
You must be logged in to reply to this topic. Login to reply