Current location: Hot Scripts Forums » Programming Languages » ASP » Operation is not allowed when the object is closed.

Operation is not allowed when the object is closed.

 
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 05-20-08, 01:45 PM
lamore lamore is offline
New Member
 
Join Date: May 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Operation is not allowed when the object is closed.

Hi all, I get the following error when I try and run my code. I looked it up but it says it from closing the recordset. The recordset isn't closed until later in the code but maybe I'm missing something. Note, I got this code online and revised it to use in my application. Note, the error is on line 55 which is:
<% If objRS.BOF and objRS.EOF Then %>
asp Code:
  1. <%
  2. Option Explicit
  3.  
  4. Dim DBName, objConn, objRS, strSQL, Cat, Search
  5.   Dim icount
  6.   icount = 0
  7.   DBName = server.mappath("DB/orders.mdb")
  8.  
  9.   Cat = Request.Form( "cat" )
  10.   Search = Request.Form( "searchf" )
  11.    
  12.    
  13.    Set objConn = Server.CreateObject("ADODB.Connection")
  14.    objConn.ConnectionString = "DBQ=" & DBName & ";Driver={Microsoft Access Driver (*.mdb)};"
  15.    
  16.  
  17.    Set objRS = Server.CreateObject("ADODB.Recordset")
  18.      objConn.objRS.Open
  19.        
  20.      IF len(Search) <> 0 Then
  21.        Select Case Cat
  22.       
  23.         Case "Due Date"
  24.  
  25.           strSQL = "SELECT * FROM  Tasks WHERE Tasks.[Due Date] LIKE '%" & Search & "%' ORDER BY Due Date DESC"
  26.               Set objRS= objConn.execute(strSQL)
  27.         Case "Category"
  28.           strSQL = "SELECT * FROM Tasks WHERE Tasks.Category LIKE '%" & Search & "%' ORDER BY Due Date DESC"
  29.               Set objRS= objConn.execute(strSQL)
  30.         Case "Responsible Person - Name"
  31.           strSQL = "SELECT * FROM Tasks WHERE Tasks.[Responsible Person - Name] LIKE '%" & Search & "%' ORDER BY Due Date DESC"
  32.                Set objRS= objConn.execute(strSQL)
  33.         
  34.       End Select
  35.     Else
  36.       Response.Write "No Value Entered"
  37.       Response.Redirect "Default.asp"
  38.     End If
  39.    
  40. %>
  41. <html>
  42. <head>
  43. <title>Search Results</title>
  44. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  45. <link rel="stylesheet" href="css/admin.css" type="text/css">
  46. <script language="JavaScript">
  47. <!--
  48. function MM_jumpMenu(targ,selObj,restore){ //v3.0
  49.   eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  50.   if (restore) selObj.selectedIndex=0;
  51. }
  52. //-->
  53. </script>
  54. </head>
  55.  
  56. <body bgcolor="#ecece4" text="#000000">
  57. <% If objRS.BOF and objRS.EOF Then %>
  58. <font size="2" face="Arial, Helvetica, sans-serif"><b><font color="#FF0000">No
  59. Records Found</font></b></font>
  60. <% Else %>
  61. <form name="form1" class="normaltxt">
  62.     <table width="100%" border="0" cellspacing="4" cellpadding="0">
  63.       <tr>
  64.         <td width="33%" class="normaltxt">Status:
  65.           <select name="menu1" onChange="MM_jumpMenu('parent',this,0)" class="normaltxt">
  66.             <option value="orderreport.asp?SORT=1&STATUS=ALL" selected>All</option>
  67.             <option value="orderreport.asp?SORT=2&STATUS=OPEN" >Open</option>
  68.             <option value="orderreport.asp?SORT=3&STATUS=CLOSED" >Complete</option>
  69.           </select>
  70.         </td>
  71.        
  72.       <td width="33%" class="normaltxt">Sort By:
  73.         <select name="menu3" onChange="MM_jumpMenu('parent',this,0)" class="normaltxt">
  74.           <option value="orderreport.asp?SORT=1&STATUS=ALL">Due Date</option>
  75.           <option value="orderreport.asp?SORT=9&STATUS=ALL" selected>Weeks Before Shutdown/option>
  76.           <option value="orderreport.asp?SORT=10&STATUS=ALL">Category</option>
  77.           <option value="orderreport.asp?SORT=11&STATUS=ALL">Responsible Person - Name</option>
  78.         </select>
  79.       </td>
  80.       <td width="33%" class="normaltxt">&nbsp;</td>
  81.       </tr>
  82.     </table> 
  83.   </form>
  84.  
  85. <table width="795" border="0" cellspacing="0" cellpadding="1" bgcolor="#003366">
  86.   <tr>
  87.     <td>
  88.       <table width="114%" border="0" cellspacing="1" cellpadding="3" class="BlkTextStd">
  89.         <tr bgcolor="#FFCC66">
  90.           <td class="headers1" width="43" height="19">Due Date</td>
  91.           <td class="headers1" width="63" height="19">Weeks Before Shutdown</td>
  92.           <td class="headers1" width="49" height="19">Category</td>
  93.           <td class="headers1" width="496" height="19">Tasks</td>
  94.           <td class="headers1" width="52" height="19">Responsible Person - Title</td>
  95.           <td class="headers1" width="47" height="19">Responsible Person - Name</td>
  96.         </tr>
  97.         <%
  98.         While NOT objRS.EOF
  99.        
  100.         If Eval(icount\2 = icount/2) Then
  101.           color = "#ecece4"
  102.         ELSE
  103.           color = "#fdfdfc"
  104.         END IF
  105.         %>
  106.         <TR BGCOLOR=<%= color %>>
  107.           <td class="normaltxt" width="43">&nbsp; <%= objRS("Due Date") %></td>
  108.           <td class="normaltxt" width="63">&nbsp; <a href="process.asp?ID=<%= objRS("OrderID") %>"><%= objRS("Weeks before Shutdown") %></a> </td>
  109.           <td class="normaltxt" width="49">&nbsp; <%= objRS("Catergory") %> </td>
  110.           <td class="normaltxt" width="496">&nbsp; <%= objRS("Tasks") %> </td>
  111.           <td class="normaltxt" width="52">&nbsp; <%= objRS("Responsible Person - Title") %> </td>
  112.           <td class="normaltxt" width="47">&nbsp; <%= objRS("Responsible Person - Name") %> </td>
  113.         </tr>
  114.         <%
  115.           icount=icount+1
  116.           objRS.MoveNext
  117.           Wend
  118.           'objRS.Close
  119.        %>
  120.       
  121.       </table>
  122. </td>
  123.   </tr>
  124. </table>
  125. </body>
  126. </html>
  127. <% End IF %>
I would appreciate any help on this.

Thanks,
Lenny

Last edited by Nico; 05-20-08 at 04:57 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Operation is not allowed when the object is closed. Problem peasoup ASP 2 11-02-06 03:44 PM
Error in OleDBConnection : Object reference not set to an instance of an object pvsunil Windows .NET Programming 1 04-22-05 02:45 PM
javascript object hidden by flash object morlack JavaScript 1 03-09-04 06:36 AM
Object Oriented Programming Stefan PHP 29 12-30-03 12:22 PM


All times are GMT -5. The time now is 12:21 PM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.