Note that there are some explanatory texts on larger screens.

plurals
  1. POCall to stored procedure fails in classic asp when the stored proc INSERTs or UPDATEs tables
    primarykey
    data
    text
    <p>I am developing/maintaining <strong>classic asp pages</strong> and asp code on a Windows 7 PC with data taking from an <strong>Sqlserver/Express 2008/R2</strong>.</p> <p>In this code I use a stored procedure to log-on to the web site. </p> <ul> <li><p>If the login-id and password combination is correct some tables are updated using UPDATE or INSERT.</p></li> <li><p>If the login-id or password is not correct, no logging is issued( so no tables are updated ).</p></li> </ul> <p><strong>A result set is returned</strong> 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).</p> <p><em>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.</em></p> <p>The code, which works on other IIS/Sqlservers combinations does not work on my development PC.</p> <p>Any idea why? </p> <p>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.</p> <p>To be complete I will now give the routine ( but you will see it's very straight forward ):</p> <pre class="lang-vb prettyprint-override"><code> 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 " &amp; SqlString( psNickName ) &amp; "," &amp; _ SqlString(psPassWord) &amp; "," &amp; _ SqlString(Request.ServerVariables("REMOTE_ADDR")) &amp; "," &amp; _ 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 &lt;&gt; -1 then DoLogon = True Klant_IsLoggedOn = 1 else DoLogon = False Klant_IsLoggedOn = 0 end if call SetVarValue(cKlant_IsLoggedOn, Klant_IsLoggedOn) end function </code></pre> <p>The following error is displayed when the <code>objRec.Close</code> line is present:</p> <pre><code>ADODB.Recordset error '800a0e78' Operation is not allowed when the object is closed. </code></pre> <ul> <li><p>Replacing the <code>exec sp_...</code> with a <code>select * from ...</code> works. So I presume the code it self is correct.</p></li> <li><p>DbOpen and DbClose will allocate <code>objRec</code> and <code>objConn</code> and connect to / disconnect from the server (here SqlServer).</p></li> </ul> <p><strong>UPDATE AND SOLUTION</strong></p> <p>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.</p> <p>As the first statement if the stored procedure I have added </p> <p>set nocount on</p> <p>And this seems to be the trick to get it working.</p> <p>I have not found why this is necessary (from a technically view point), just that including <code>set nocount on</code> will speed up the stored procedures, but at last I have running stored procedures in combination with classic ASP again !</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload