1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need Help On Search page using menu pulldown

Discussion in 'C#' started by maven, Nov 2, 2006.

  1. #1
    hello guys, i need help on this search page. the search page , http://www.mellon.com.sg/shop/search.asp , has 2 options for users to find products, either the search text field or the pull down sub category menu search.
    The search text field works but not the pull down sub category menu search. The latest error which was displayed when it is
    Error Type:
    Microsoft VBScript runtime (0x800A01A8)
    Object required: ''
    /shop/search.asp, line 347 (refer to code in bold)
    I wish i can solve this myself which i am so clueless but i appreciate if anyone is kind enough to let me know the problem and the amendment to make.
    
    
    <%@ Language=VBScript %>
    <% pageTitle = "Search Page" %>
    <!-- #include file="adovbs.inc" -->
    <%
    ' Create and open connection        
    Dim vPath, pPath, ConString
    
    vPath = "BMP.mdb" 'use this one if database is in root of cart folder
    'vPath = "\database\BMP.mdb" 'use this one if database is in root of your website
    pPath = Server.MapPath( vPath )
    
    ConString = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & pPath & ";" & "JET OLEDB:"
    Dim Conn, rsProduct_SearchAll, rsProduct_Brand
    Set Conn = Server.CreateObject("ADODB.Connection")
    Conn.Open ConString
    
    
    	chkText = Request.form("chkText")
        strText = cstr(Request.form("strText"))
        strText = uCase(strText)    
        
    
    	strTextWhere = ""   
        strCatWhere = ""
    
       IF chkText = "yes" AND strText <> "" then ' Look for: search method on -> Product_ID, Model, Description, Category        
    			Response.Redirect "list_item.asp?ThestrText=" & strText & "&ThechkText=" & chkText
       END IF 
    
    	IF Request.Form("CatalogNameSelected") = 1 then 
    	
         ThegetCatalogID = Request.Form("getCatalogID")  	   'get getCatalogID = > catalogID
    	 TheModel = Trim(Request.Form("Model"))
          TheBrand = Trim(Request.Form("Brand")) 
    	 TheSubCategory= Trim(Request.Form("Sub_Category"))	 
          Set objRSCatalogID = Server.CreateObject("ADODB.RecordSet")      'Catalog Name Listing - pull down	 
          objRSCatalogID.Open "SELECT [CatalogID], [Sub_Category] FROM [Product] WHERE [CatalogID] = '"& ThegetCatalogID & "'", Conn
    	   if NOT objRSCatalogID.EOF then
    	  TheCatalogID = trim(objRSCatalogID(0).value)
          TheName = trim(objRSCatalogID(1).value) 
    	END IF
    	 
         	 If  ThegetCatalogID <> "--select CatalogName--" then 
    			Set objRSBrandListName = Server.CreateObject("ADODB.RecordSet")      'PRODUCT TABLE
    			objRSBrandListName.Open "SELECT DISTINCT [Sub_Category], [Model] FROM [Product] WHERE [Model] = '" & TheModel & "' AND [CatalogID] = '" & TheCatalogID & "'", Conn
    			
    				else
    	   		Response.write "No records for the Catatlog id "& ThegetCatalogID  
    	   	end if 
    
    						Response.Redirect "list_item.asp?strSub_category=" & TheSubCategory & "&ThechkText=" & chkText & "&TheBrand=" & TheBrand & "&ThegetCatalogID=" & TheCatalogID 
    				end if
    	  %>
    
    
    function doSubmit(myFormObj) {   
          myFormObj.submit();
          return true;
        }
    
        <form action="/Shop/search.asp" method="post" id="form1" name="form1">
    	
     <span class="style35 style40"><strong> please  type search according to description,brand,category</strong></span>	  <br>
    	  <input type="text" name="strText">
    	  <br>
    	   <input type="hidden" name="chkText" value="yes">
    	  <input type="submit" value="Search" id="submit1" 
    name="submit1">
    	  <br>
    	  <br>
            OR Do a search by using the jump menu for Catalog Name & Brand 
            <table width="448" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" dwcopytype="CopyTableRow">
    	
          <tr>
            <td width="211" height="64" nowrap bordercolor="#FFFFFF" bgcolor="#FFFF00" class="style3">
              <span class="themehead1">Catalog Name  </span><span class="style43">:</span>          
              <select name="getCatalogID" size="1" onChange="doSubmit(this.form)">
              <%  
    		  if TheName = "--select CatalogName--" then  %>
              <option value="">
              <% else %>
              <option value="<%=TheCatalogID%>">
               </option>
              [B]<% objRSCatalogID.MoveFirst  [/B]			  Do Until objRSCatalogID.EOF    
    %>
              <option value="<%=trim(objRSCatalogID(1).value)%>"><%=trim(objRSCatalogID(0).value)%></option>
              <%
    					objRSCatalogID.MoveNext 
    			  Loop
    			  
    %>
            </select></td>
    	  <tr>
    	    <td width="237" height="64" nowrap bgcolor="#FFFF00" class="style3"><span class="themehead1"> </span>: 
                        </td>
    		
    	  </tr>
        <tr>
          <td height="48" align="center" bgcolor="#FFFF00" class="style2"> <font face="Arial, Helvetica, sans-serif"> 
            <input type="reset" name="Reset" value="Reset">
            <input type="hidden" name="CatalogNameSelected" value="1">
    		
            <!--<input type="Button" value="Exit" onClick="exit()">-->
            </font> </td>
        </tr>
       </table>
        <p>*    </p>
        </form>
    <%
    objRSCatalog.Close
    set objRSCatalog = Nothing
    'objRSCatalogID.Close
    set objRSCatalogID = Nothing
    Conn.Close
    set Conn = Nothing
    End if
    %> </td>
    
    Code (markup):

     
    maven, Nov 2, 2006 IP
  2. ludwig

    ludwig Notable Member

    Messages:
    2,253
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    225
    #2
    maybe try this
    Put the DO in a new line
     
    ludwig, Nov 3, 2006 IP
  3. maven

    maven Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    hi, can you tell me how to do this? i am unclear about it. thanks
     
    maven, Nov 6, 2006 IP
  4. ludwig

    ludwig Notable Member

    Messages:
    2,253
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    225
    #4
    look at your code,

    find this line
    replace it with these lines
     
    ludwig, Nov 6, 2006 IP
  5. maven

    maven Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    hey ludwig, well thanks for the info and I'm sorry that i asked you earlier again because i thought you meant putting the do in a new statement line or something . The code is still the same as you suggested to change but the error is still the same Error Type:
    Microsoft VBScript runtime (0x800A01A8)
    Object required: ''
    /shop/searchpageNov06.asp, line 301

    which refers to this line highlighted in red. i am so sorry for the trouble but i wish i can solve this but i am not sure what the error is about.
    
    <%@ Language=VBScript %>
    <% pageTitle = "Search Page" %>
    <!-- #include file="adovbs.inc" -->
    <%
    ' Create and open connection        
    Dim vPath, pPath, ConString
    
    vPath = "BMP.mdb" 'use this one if database is in root of cart folder
    'vPath = "\database\BMP.mdb" 'use this one if database is in root of your website
    pPath = Server.MapPath( vPath )
    
    ConString = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & pPath & ";" & "JET OLEDB:"
    Dim Conn, rsProduct_SearchAll, rsProduct_Brand
    Set Conn = Server.CreateObject("ADODB.Connection")
    Conn.Open ConString
    
    
    	chkText = Request.form("chkText")
        strText = cstr(Request.form("strText"))
        strText = uCase(strText)    
        
    
    	strTextWhere = ""   
        strCatWhere = ""
    
       IF chkText = "yes" AND strText <> "" then ' Look for: search method on -> Product_ID, Model, Description, Category        
    			Response.Redirect "list_item.asp?ThestrText=" & strText & "&ThechkText=" & chkText
       END IF 
    
    	IF Request.Form("CatalogNameSelected") = 1 then 
    	
         ThegetCatalogID = Request.Form("CatalogID")  	   'get getCatalogID = > catalogID
    	 TheModel = Trim(Request.Form("Model"))
          TheBrand = Trim(Request.Form("Brand")) 
    	 TheSubCategory= Trim(Request.Form("Sub_Category"))	 
          Set objRSCatalogID = Server.CreateObject("ADODB.RecordSet")      'Catalog Name Listing - pull down	 
          objRSCatalogID.Open "SELECT [CatalogID], [Sub_Category] FROM [Product] WHERE [CatalogID] = '"& ThegetCatalogID & "'", Conn
    	   if NOT objRSCatalogID.EOF then
    	  TheCatalogID = trim(objRSCatalogID(0).value)
          TheName = trim(objRSCatalogID(1).value) 
    	END IF
    	 
         	 If  ThegetCatalogID <> "--select CatalogName--" then 
    			Set objRSBrandListName = Server.CreateObject("ADODB.RecordSet")      'PRODUCT TABLE
    			objRSBrandListName.Open "SELECT DISTINCT [Sub_Category], [Model] FROM [Product] WHERE [Model] = '" & TheModel & "' AND [CatalogID] = '" & TheCatalogID & "'", Conn
    			
    				else
    	   		Response.write "No records for the Catalog id "& ThegetCatalogID  
    	   	end if 
    
    						Response.Redirect "list_item.asp?strSub_category=" & TheSubCategory & "&ThechkText=" & chkText & "&TheBrand=" & TheBrand & "&ThegetCatalogID=" & TheCatalogID 
    				end if
    		
    %>
     <form action="/Shop/search.asp" method="post" id="form1" name="form1">
    	
        
         
            <span class="style35 style40"><strong> please  type search according to description,brand,category</strong></span>	  <br>
    	  <input type="text" name="strText">
    	  <br>
    	   <input type="hidden" name="chkText" value="yes">
    	  <input type="submit" value="Search" id="submit1" 
    name="submit1">
    	  <br>
    	  <br>
            OR Do a search by using the jump menu for Catalog Name &amp; Brand 
            <table width="448" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" dwcopytype="CopyTableRow">
    	
          <tr>
            <td width="211" height="64" nowrap bordercolor="#FFFFFF" bgcolor="#FFFF00" class="style3">
              <span class="themehead1">Catalog Name  </span><span class="style43">:</span>          
              <select name="getCatalogID" size="1" onChange="doSubmit(this.form)">
              <%  
    		  if TheName = "--select CatalogName--" then  %>
              <option value="">
              <% else %>
              <option value="<%=TheCatalogID%>">
               </option>
             [COLOR="Red"] <% objRSCatalogID.MoveFirst
              Do Until objRSCatalogID.EOF    
               %>[/COLOR]          <option value="<%=trim(objRSCatalogID(1).value)%>"><%=trim(objRSCatalogID(0).value)%></option>
              <%
    					objRSCatalogID.MoveNext 
    			  Loop
    			  
    %>
            </select></td>
    	  <tr>
    	    <td width="237" height="64" nowrap bgcolor="#FFFF00" class="style3"><span class="themehead1"> </span>: 
                        </td>
    		
    	  </tr>
        <tr>
          <td height="48" align="center" bgcolor="#FFFF00" class="style2"> <font face="Arial, Helvetica, sans-serif"> 
            <input type="reset" name="Reset" value="Reset">
            <input type="hidden" name="CatalogNameSelected" value="1">
    		
            <!--<input type="Button" value="Exit" onClick="exit()">-->
            </font> </td>
        </tr>
       </table>
        <p>&nbsp;    </p>
        </form>
    <%
    objRSCatalogID.Close
    set objRSCatalog = Nothing
    'objRSCatalogID.Close
    set objRSCatalogID = Nothing
    Conn.Close
    set Conn = Nothing
    End if
    %> </td
    
    Code (markup):
     
    maven, Nov 6, 2006 IP
  6. ludwig

    ludwig Notable Member

    Messages:
    2,253
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    225
    #6
    the problem is that you do not SET a recordset

    then let me know about the results

    edit: forgot to mention, put it on top after
     
    ludwig, Nov 7, 2006 IP
  7. maven

    maven Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks for the helo, ludwig. i did what you suggested but I get this error message displayed which says
    Error Type:
    ADODB.Recordset (0x800A0E78)
    Operation is not allowed when the object is closed.
    /shop/searchpageNov06.asp, line 301

    Below is the code for line 301 highlighted in red
    
    <%@ Language=VBScript %>
    <% pageTitle = "Search Page" %>
    <!-- #include file="adovbs.inc" -->
    <%
    ' Create and open connection        
    Dim vPath, pPath, ConString
    Set objRSCatalogID=Server.CreateObject("ADODB.Recordset") 
    vPath = "BMP.mdb" 'use this one if database is in root of cart folder
    'vPath = "\database\BMP.mdb" 'use this one if database is in root of your website
    pPath = Server.MapPath( vPath )
    
    ConString = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & pPath & ";" & "JET OLEDB:"
    Dim Conn, rsProduct_SearchAll, rsProduct_Brand
    Set Conn = Server.CreateObject("ADODB.Connection")
    Conn.Open ConString
    
    
    	chkText = Request.form("chkText")
        strText = cstr(Request.form("strText"))
        strText = uCase(strText)    
        
    
    	strTextWhere = ""   
        strCatWhere = ""
    
       IF chkText = "yes" AND strText <> "" then ' Look for: search method on -> Product_ID, Model, Description, Category        
    			Response.Redirect "list_item.asp?ThestrText=" & strText & "&ThechkText=" & chkText
       END IF 
    
    	IF Request.Form("CatalogNameSelected") = 1 then 
    	
         ThegetCatalogID = Request.Form("CatalogID")  	   'get getCatalogID = > catalogID
    	 TheModel = Trim(Request.Form("Model"))
          TheBrand = Trim(Request.Form("Brand")) 
    	 TheSubCategory= Trim(Request.Form("Sub_Category"))	 
          Set objRSCatalogID = Server.CreateObject("ADODB.RecordSet")      'Catalog Name Listing - pull down	 
          objRSCatalogID.Open "SELECT [CatalogID], [Sub_Category] FROM [Product] WHERE [CatalogID] = '"& ThegetCatalogID & "'", Conn
    	   if NOT objRSCatalogID.EOF then
    	  TheCatalogID = trim(objRSCatalogID(0).value)
          TheName = trim(objRSCatalogID(1).value) 
    	END IF
    	 
         	 If  ThegetCatalogID <> "--select CatalogName--" then 
    			Set objRSBrandListName = Server.CreateObject("ADODB.RecordSet")      'PRODUCT TABLE
    			objRSBrandListName.Open "SELECT DISTINCT [Sub_Category], [Model] FROM [Product] WHERE [Model] = '" & TheModel & "' AND [CatalogID] = '" & TheCatalogID & "'", Conn
    			
    				else
    	   		Response.write "No records for the Catalog id "& ThegetCatalogID  
    	   	end if 
    
    						Response.Redirect "list_item.asp?strSub_category=" & TheSubCategory & "&ThechkText=" & chkText & "&TheBrand=" & TheBrand & "&ThegetCatalogID=" & TheCatalogID 
    				end if	
    %>
    
    <html>
    
    <head>
    	<title>Mellon Commercial Pte Ltd</title>
    	<SCRIPT LANGUAGE="JavaScript">
    <!--
    
    
    
    function doSubmit(myFormObj) {   
          myFormObj.submit();
          return true;
        }
    Search our catalogs</strong></font>    </span>
        <form action="/Shop/search.asp" method="post" id="form1" name="form1">
    	
        
         
            <span class="style35 style40"><strong> please  type search according to description,brand,category</strong></span>	  <br>
    	  <input type="text" name="strText">
    	  <br>
    	   <input type="hidden" name="chkText" value="yes">
    	  <input type="submit" value="Search" id="submit1" 
    name="submit1">
    	  <br>
    	  <br>
            OR Do a search by using the jump menu for Catalog Name &amp; Brand 
            <table width="448" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" dwcopytype="CopyTableRow">
    	
          <tr>
            <td width="211" height="64" nowrap bordercolor="#FFFFFF" bgcolor="#FFFF00" class="style3">
              <span class="themehead1">Catalog Name  </span><span class="style43">:</span>          
              <select name="getCatalogID" size="1" onChange="doSubmit(this.form)">
              <%  
    		  if TheName = "--select CatalogName--" then  %>
              <option value="">
              <% else %>
              <option value="<%=TheCatalogID%>">
               </option>
              [COLOR="Red"]<% objRSCatalogID.MoveFirst [/COLOR]			  Do Until objRSCatalogID.EOF %>
              <option value="<%=trim(objRSCatalogID(1).value)%>"><%=trim(objRSCatalogID(0).value)%></option>
              <%
    					objRSCatalogID.MoveNext 
    			  Loop
    			  
    %>
            </select></td>
    	  <tr>
    	    <td width="237" height="64" nowrap bgcolor="#FFFF00" class="style3"><span class="themehead1"> </span>: 
                        </td>
    		
    	  </tr>
        <tr>
          <td height="48" align="center" bgcolor="#FFFF00" class="style2"> <font face="Arial, Helvetica, sans-serif"> 
            <input type="reset" name="Reset" value="Reset">
            <input type="hidden" name="CatalogNameSelected" value="1">
    		
            <!--<input type="Button" value="Exit" onClick="exit()">-->
            </font> </td>
        </tr>
       </table>
        <p>&nbsp;    </p>
        </form>
    <%
    objRSCatalogID.Close
    set objRSCatalog = Nothing
    'objRSCatalogID.Close
    set objRSCatalogID = Nothing
    Conn.Close
    set Conn = Nothing
    End if
    %> </td>
    
    Code (markup):
     
    maven, Nov 7, 2006 IP
  8. ludwig

    ludwig Notable Member

    Messages:
    2,253
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    225
    #8
    you have not populated your RS but you are trying to retrieve data from it.

    You need to check if the RS is empty or no, if it is empty you should not try to get any values from it
     
    ludwig, Nov 7, 2006 IP
  9. maven

    maven Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    hey ludwig, thanks for the message. i tried to figure it myself but i just dont come to a solution.The search page has a search text field and a pull down menu. do i have to create separate recordset for those 2 search functions?I am not sure and appreciate if you could guide me . thanks
     
    maven, Nov 10, 2006 IP