Reputation: 5058
I am developing/maintaining classic asp pages and asp code on a Windows 7 PC with data taking from an Sqlserver/Express 2008/R2.
In this code I use a stored procedure to log-on to the web site.
If the login-id and password combination is correct some tables are updated using UPDATE or INSERT.
If the login-id or password is not correct, no logging is issued( so no tables are updated ).
A result set is returned with some fields on both cases (with a field set to -1 or the internal user nr depending on the correctness of login-id and password).
I have been using this same routine for over 5 years now , running on all sorts of IIS servers and with all sorts of Sqlservers.
The code, which works on other IIS/Sqlservers combinations does not work on my development PC.
Any idea why?
Since it is a development environment I use the sqlserver SA account with the appropriate password. So as far as I can tell, this SA user should have all appropriate rights.
To be complete I will now give the routine ( but you will see it's very straight forward ):
function DoLogon( byval psNickName, byval psPassword)
dim sSql
DoLogon = False
psNickName = Trim(psNickName)
psPassword = Trim(psPassword)
if (psNickName = "") then exit function
if (psPassword = "") then exit function
' on error Resume Next
call DbOpen
sSql = "exec sp_EcomLogon " & SqlString( psNickName ) & "," & _
SqlString(psPassWord) & "," & _
SqlString(Request.ServerVariables("REMOTE_ADDR")) & "," & _
Trim(cStr(Session.SessionId))
objRec.Open sSql ,objConn ' ,adOpenStatic,adLockReadOnly ,adCmdText
Klant_NetId = FldDft("K_NetId",-1)
Call SetVarValue(cKlant_NetId,Klant_NetId)
objRec.Close
call DbClose
if Klant_NetId <> -1 then
DoLogon = True
Klant_IsLoggedOn = 1
else
DoLogon = False
Klant_IsLoggedOn = 0
end if
call SetVarValue(cKlant_IsLoggedOn, Klant_IsLoggedOn)
end function
The following error is displayed when the objRec.Close
line is present:
ADODB.Recordset error '800a0e78'
Operation is not allowed when the object is closed.
Replacing the exec sp_...
with a select * from ...
works. So I presume the code it self is correct.
DbOpen and DbClose will allocate objRec
and objConn
and connect to / disconnect from the server (here SqlServer).
UPDATE AND SOLUTION
I have asked the person providing me with this solution to create an answer so I can give him proper upvotes, but in the mean time I will present the solution here.
As the first statement if the stored procedure I have added
set nocount on
And this seems to be the trick to get it working.
I have not found why this is necessary (from a technically view point), just that including set nocount on
will speed up the stored procedures, but at last I have running stored procedures in combination with classic ASP again !
Upvotes: 1
Views: 2102
Reputation: 13533
It could be that the stored procedure that you are accessing is executing with an error. I would suggest that you write out the string sSql to screen copy it and execute it in query analyser to troubleshoot it.
Upvotes: 2
Reputation: 4509
I ran into a similar problem and in my case the issue was permissions on the table I was selecting from. I didn't have select permissions and it would close the connection. Now you mentioned that you are using the sa account so this should have permissions to all the functionality, but I would double check to make sure that this is true. HTH
Wade
Upvotes: 0