Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where Am I Erring??????

Status
Not open for further replies.

arpan

Programmer
Oct 16, 2002
336
IN
An ASP page invokes the following simple stored procedure (SQL Server 7.0):

CREATE PROCEDURE LeaveBalance
@ccode varchar(10)
AS
DECLARE
@sql varchar(8000)
SET @sql='SELECT em.ECode,em.EName,vm.CL,vm.SL,vm.PL,vm.Entl FROM ' +
@ccode + '_EMST AS em INNER JOIN ' +
@ccode + '01VMST AS vm ON
em.ECode=vm.ECode'
EXEC (@sql)

This is the ASP code:

<%
Dim strSQL,objRS,strCCode
strCCode=Request.QueryString(&quot;ccode&quot;)
strSQL=&quot;EXEC LeaveBalance '&quot; & strCCode & &quot;'&quot;
Set objRS=objConn.Execute(strSQL)
%>
<table border=2>
<tr>
<th>NAME</th>
<th>CASUAL LEAVE</th>
<th>SICK LEAVE</th>
<th>PRIVILEGE LEAVE</th>
<th>ENTL</th>
</tr>
<%
Do Until(objRS.EOF)
%>
<tr>
<td><%= objRS(&quot;EName&quot;) %></td>
<td align=center><%= objRS(&quot;CL&quot;) %></td>
<td align=center><%= objRS(&quot;SL&quot;) %></td>
<td align=center><%= objRS(&quot;PL&quot;) %></td>
<td align=center><%= objRS(&quot;Entl&quot;) %></td>
</tr>
<%
objRS.MoveNext
Loop
%>

When I execute the above ASP code, I am getting the error as 'Operation is not allowed when the object is closed' which points to the Do Until(objRS.EOF) line. What is going wrong here? Please note that instead of using the stored procedure, if I am using the following SELECT statement in ASP, the correct recordset is retrieved:

<%
strSQL=&quot;SELECT em.ECode,em.EName,vm.CL,vm.SL,vm.PL,vm.Entl FROM &quot; & strCCode & &quot;_EMST AS em INNER JOIN &quot; & strCCode & &quot;01VMST AS vm ON em.ECode=vm.ECode&quot;
%>

Also if the above stored procedure is executed in the Query Analyzer using EXEC LeaveRecords 'QL', then also the correct recordset gets retrieved. Why is this error popping up?

Thanks,

Arpan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top