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):
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 & 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> </p> </form> <% objRSCatalogID.Close set objRSCatalog = Nothing 'objRSCatalogID.Close set objRSCatalogID = Nothing Conn.Close set Conn = Nothing End if %> </td Code (markup):
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
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 & 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> </p> </form> <% objRSCatalogID.Close set objRSCatalog = Nothing 'objRSCatalogID.Close set objRSCatalogID = Nothing Conn.Close set Conn = Nothing End if %> </td> Code (markup):
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
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