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("ccode"
strSQL="EXEC LeaveBalance '" & strCCode & "'"
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("EName"
%></td>
<td align=center><%= objRS("CL"
%></td>
<td align=center><%= objRS("SL"
%></td>
<td align=center><%= objRS("PL"
%></td>
<td align=center><%= objRS("Entl"
%></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="SELECT em.ECode,em.EName,vm.CL,vm.SL,vm.PL,vm.Entl FROM " & strCCode & "_EMST AS em INNER JOIN " & strCCode & "01VMST AS vm ON em.ECode=vm.ECode"
%>
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
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("ccode"
strSQL="EXEC LeaveBalance '" & strCCode & "'"
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("EName"
<td align=center><%= objRS("CL"
<td align=center><%= objRS("SL"
<td align=center><%= objRS("PL"
<td align=center><%= objRS("Entl"
</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="SELECT em.ECode,em.EName,vm.CL,vm.SL,vm.PL,vm.Entl FROM " & strCCode & "_EMST AS em INNER JOIN " & strCCode & "01VMST AS vm ON em.ECode=vm.ECode"
%>
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