Jump to content

negative value (-1) returned from my Recordcount


Recommended Posts

Good day, i have an asp classic application.Its actually an eOffice system, but when i try to retrieve the number of people that are present,absent and on-leave, it returns -1I have tried all means online but to no avail..will wait for you wonderful programmers and would really appreciate your help..regards

<!--#include file="utils.asp"--><!--#include file="Js.asp"--><%dim rst,sqlsql="SELECT St_ID,  st_abbr, st_name, st_type_id, st_parent_id FROM e_structure WHERE (st_parent_id =0)" 'set rst1= objVO.OpenRecordSet(cstr(sql)) st_code,Set rst1= eOfficeDsn.Execute(sql)If rst1.eof then	Response.Write"sorry no reord found"	end if  %><table width="100%" border="0" cellpadding="2" cellspacing="2">  <tr> 	<td class="SubLevelText"><div align="center"></div></td>	<td class="SubLevelText"><div align="center"></div></td>	<td width="13%" class="SubLevelText"> <div align="left">Messages</div></td>	<td width="15%" class="SubLevelText"> <div align="left">Message Center</div></td>	<td width="16%" class="SubLevelText">Core Functions</td>	<td width="5%" class="SubLevelText"><div align="center"><img src="images/greebbanda16x16.gif" width="13" height="15"></div></td>	<td width="4%" class="SubLevelText"><div align="center"><img src="images/redbanda16x16.gif" width="13" height="16"></div></td>	<td width="4%" class="SubLevelText"><div align="center"><img src="images/graybanda16x16.gif" width="13" height="15"></div></td>  </tr>  <% while not rst1.EOF 		'REM line below is geting childs of structure id.if structure id is last chid then if condition will return that child		getnodetree(rst1.fields("st_id"))		stid=glbNodeList		'REM This code is counting Red email and showing it in main page index.htm		if stid="" then			SQL="SELECT Fromid from ivo_readmail WHERE [To] = "& Session("EmpId") &"  and To_St_ID =" & rst1.fields("st_id") & ""		else			SQL="SELECT Fromid from ivo_readmail WHERE [To] = "& Session("EmpId") &"  and To_St_ID in(" & stid & ")"			glbNodeList=""		end if		'set rst=objvo.openrecordset(cstr(sql),3)		Set rst= eOfficeDsn.Execute(sql)				Readmails=rst.recordcount 		rst.close		set rst= nothing		'REM this code is counting total emails		if stid="" then			SQL="SELECT Fromid from ivo_readmail WHERE [To] ="& Session("EmpId") &" and To_St_ID ="& rst1.fields("st_id")&""		else 			SQL="SELECT Fromid from ivo_readmail WHERE [To] ="& Session("EmpId") &" and To_St_ID in(" & stid & ")"			glbNodeList=""		end if		'set rst=objvo.openrecordset(cstr(sql),3)		Set rst= eOfficeDsn.Execute(sql)		totalmails=rst.recordcount 		rst.close		set rst= nothing ' end of counting total emails		'REM This code is counting employees those are present absent and on leave, and showing it in main page index.htm		if stid="" then			SQL="SELECT Attandance FROM ivo_attandance where st_id="& rst1.fields("st_id") & " and Attandance ='P' and convert(varchar,datetime,101)= convert(varchar,GETDATE(),101)"			else			SQL="SELECT Attandance FROM ivo_attandance where st_id in("& stid &") and Attandance ='P' and convert(varchar,datetime,101)= convert(varchar,GETDATE(),101)"			glbNodeList=""		end if 		'set rst=objvo.openrecordset(cstr(sql),3)		Set rst= eOfficeDsn.Execute(sql)		Present=rst.recordcount 		rst.close		set rst= nothing 'end of counting total present employees		REM code below is counting absent employees 		if stid="" then			SQL="SELECT Attandance FROM ivo_attandance where st_id="& rst1.fields("st_id")& " and Attandance ='A' and convert(varchar,datetime,101)= convert(varchar,GETDATE(),101)"			else			SQL="SELECT Attandance FROM ivo_attandance where st_id in("& stid & ") and Attandance ='A' and convert(varchar,datetime,101)= convert(varchar,GETDATE(),101)"			glbNodeList=""		end if		'set rst=objvo.openrecordset(cstr(sql),3)		Set rst= eOfficeDsn.Execute(sql)		Absent=rst.recordcount 		rst.close		set rst= nothing ' End of counting absent employess		REM following is counting Employee on leave		if stid ="" then			SQL="SELECT Attandance FROM ivo_attandance where st_id="& rst1.fields("st_id")& " and Attandance ='L' and convert(varchar,datetime,101)= convert(varchar,GETDATE(),101)"		else			SQL="SELECT Attandance FROM ivo_attandance where st_id in("& stid & ") and Attandance ='L' and convert(varchar,datetime,101)= convert(varchar,GETDATE(),101) "			glbNodeList=""		end if		'set rst=objvo.openrecordset(cstr(sql),3)		Set rst= eOfficeDsn.Execute(sql)		Leave=rst.recordcount 		rst.close		set rst= nothing ' End of counting employee on leave	%>  <tr> 	<td class="SubLevelText" width="7%"> <img border="0" src="../eOffice/images/inbox16x16.gif" width="16" height="16"><a class="home" target="_blank" href="../eOffice/Messaging/LearningArchitecture.asp"> 	  </a> </td>	<td  > <a class="yellowntext"target='_blank' href="Messaging/nodedetail.asp?st_id=<%=rst1.Fields("st_id")%>"><%=rst1.Fields("st_name")%></a></td>	<td  class="SubLevelText">  (<%=totalmails%>/<%=Readmails%>)</td>	<td align="right" nowrap class="yellowntext"><div align="center"><a target="_blank" href="Messaging/mail.asp?box=mailbox&st_id=<%=rst1.fields("st_id")%>"><img border="0" src="../eOffice/images/MessagingCenter.gif" width="16" height="16"></a></div></td>	<td align="right"><div align="center"><a href="#"><img border="0" src="../eOffice/images/reportsicon.gif" width="16" height="16"></a></div><div align="left"></div></td>	<%'REM code below 3 lines is attandance report for Present absent and on leave employees%>	<td  class="yellowntext"><div align="center"><a class="yellowtext" HREF="java script:popupwide('messaging/Reports/Attandancereport.asp?stid=<%=rst1.fields("st_id")%>&action=P')"><%=Present%></a></div></td>	<td  class="yellowntext"><div align="center"><a class="yellowtext" HREF="java script:popupwide('messaging/Reports/Attandancereport.asp?stid=<%=rst1.fields("st_id")%>&action=A')"><%=Absent%></a></div></td>	<td  class="yellowntext"><div align="left"><a class="yellowtext" HREF="java script:popupwide('messaging/Reports/Attandancereport.asp?stid=<%=rst1.fields("st_id")%>&action=L')"><%=Leave%></a></div></td>  </tr>  <%	   rst1.MoveNextwendrst1.closeset rst1 = nothing  %>  <tr> 	<td colspan="7" class="SubLevelText"><div align="right"><span class="yellowtext">        Legends:</span> 		Present =<img src="images/greebbanda16x16.gif" width="13" height="15"> 		Absent =<img src="images/redbanda16x16.gif" width="13" height="16"> Leave 		=<img src="images/graybanda16x16.gif" width="13" height="15"></div></td>  </tr></table>

Link to post
Share on other sites

Where is eOfficeDsn defined? Is that in one of the include files? Is that an ADODB Command object? If it is, then the Execute method will return a Recordset object. This is what it has to say about the recordset.recordcount property:

The RecordCount property returns a long value that indicates the number of records in a Recordset object. If the Recordset object supports AbsolutePosition and AbsolutePage properties or bookmarks (if Supports(adApproxPosition) or Supports(adBookmark) returns true), this property will return the exact number of records in the Recordset. Note: This property will return -1 for a forward-only cursor; the actual count for a static or keyset cursor; and -1 or the actual count for a dynamic cursor. Note: The Recordset object must be open when calling this property. If this property is not supported it will return -1.
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...