Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Search Function Not working properly
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Search Function Not working properly

 Post Reply Post Reply
Author
simflex View Drop Down
Groupie
Groupie
Avatar

Joined: 10 November 2002
Location: United States
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote simflex Quote  Post ReplyReply Direct Link To This Post Topic: Search Function Not working properly
    Posted: 03 March 2003 at 11:09am

I have two functinalities to capture.
One allows the user to search our db using the basic search option.
The other allows the  user to search db using the advanced search option.
With the basic search option, you basically check a chekbox which disables the the advanced search option.
You then click the search button and all records in the db are displayed to the screen.
With the advanced search option, you search our db by specifying a search criterium to filter out unwanted columns.
The basic search feature appears to be working but the advanced search option is not working.
It is not working for two reasons:

One reason is because it is causing error:

Microsoft JET Database Engine (0x80040E10)
No value given for one or more required parameters.
I am not sure why it is giving this error because I used the bolean OR in my sql statements.

The other problem I am having is that when I first open the search form, all records are already displayed.
It should not be like that.
The search screen should be blank until an item is searched for.
I am dumping the code and I apologize for this dump as I don't believe I will make any sense without providing the codes.
Thanks y'all in advance

 

<html>
<head>
<body>
<%
' Constants ripped from adovbs.inc:
Const adOpenStatic = 3
Const adLockReadOnly = 1
Const adCmdText = &H0001

' Our own constants:
Const PAGE_SIZE = 5  ' The size of our pages.

' Declare our variables... always good practice!
Dim strURL     ' The URL of this page so the form will work
               ' no matter what this file is named.

Dim cnnSearch  ' ADO connection
Dim rstSearch  ' ADO recordset
Dim strDBPath  ' path to our Access database (*.mdb) file

Dim strSQL     ' The SQL Query we build on the fly
Dim strSearch  ' The text being looked for

Dim iPageCurrent ' The page we're currently on
Dim iPageCount   ' Number of pages of records
Dim iRecordCount ' Count of the records returned
Dim I            ' Standard looping variable

' Retreive the URL of this page from Server Variables
strURL = Request.ServerVariables("URL")
page = Request.QueryString("page")
basicSearch = Request.QueryString("basicSearch")
selItemNo = Request.QueryString("selItemNo")
selDivision = Request.QueryString("selDivision")
selAnswer = Request.QueryString("selAnswer")
selKeyword = Request.QueryString("selKeyword")
btnAdd = Request.QueryString("btnAdd")
advanceSearch = Request.QueryString("advanceSearch")

' Retreive the term being searched for.  I'm doing it on
' the QS since that allows people to bookmark results.
strSearch = Request.QueryString("search")
strSearch = Replace(strSearch, "'", "''")

' Retrieve page to show or default to the first
If page = "" Then
 iPageCurrent = 1
Else
 iPageCurrent = CInt(Request.QueryString("page"))
End If

' Since I'm doing this all in one page I need to see if anyone
' has searched for something.  If they have we hit the DB.
' O/W I just show the search form and quit.
%>

<%
'If strSearch <> "" Then

 ' Create an ADO Connection to connect to the sample database.
 ' We're using OLE DB but you could just as easily use ODBC or a DSN.
 Set cnnSearch = Server.CreateObject("ADODB.Connection")

 ' We're actually using SQL Server so we use this line instead:
 cnnSearch.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& server.MapPath("faqs.MDB")

 ' Build our query based on the input.

 strSQL = "SELECT * FROM FAQ "
 If advanceSearch = "ON" Then
 strSQL = strSQL & " where Answer <> 'z' "
    If selItemNo <> "" Then
     strSQL = strSQL & " OR ItemNo = " & selItemNo & " "
    End If
    If selDivision <> "" Then
     strSQL = strSQL & " OR Division LIKE '%" & selDivision & "%'   "
    End If
    If selKeyword <> "" Then
     strSQL = strSQL & " OR Question LIKE '%" & selKeyword & "%'   "
    End If
    strSQL = strSQL & " "
 End If
 strSQL = strSQL & " ORDER BY Division DESC;"

 ' Execute our query using the connection object.  It automatically
 ' creates and returns a recordset which we store in our variable.
 Set rstSearch = Server.CreateObject("ADODB.Recordset")
 rstSearch.PageSize  = PAGE_SIZE
 rstSearch.CacheSize = PAGE_SIZE
 ' Open our recordset
 rstSearch.Open strSQL, cnnSearch, adOpenStatic, adLockReadOnly, adCmdText

 ' Get a count of the number of records and pages
 ' for use in building the header and footer text.
 iRecordCount = rstSearch.RecordCount
 iPageCount   = rstSearch.PageCount

 If iRecordCount = 0 Then
  ' Display no records error.
  %>
  <p>
  No records found.  Please try again.
  </p>
  <%
 Else
  ' Move to the page we need to show.
  rstSearch.AbsolutePage = iPageCurrent

  ' Show a quick status line letting people know where they are:
  %>
  <script language="javascript">

  var Open = ""
  var Closed = ""

  function ProcessSearch(strcatvalue) {
     strAction = "Faqss.asp"
     document.forms[0].action=strAction
     document.forms[0].submit()
  }

  function preload(){
     if(document.images){
              Open = new Image(12,6)
              Closed = new Image(16,13)
              Open.src = "arrow_open.gif"
              Closed.src = "arrow.gif"
     }
  }


  function showhide(what,what2){
     if (what.style.display=='none'){
       what.style.display='';
       what2.src=Open.src
     }
     else{
        what.style.display='none'
        what2.src=Closed.src
     }
  }

  </script>
  <script language="javascript">
  function call_forms() {

              disval=(document.form1.forms.options[document.form1.forms.selectedIndex].value);
              if(disval!="none")
              {

                          window.location.href=disval;

    &

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 03 March 2003 at 11:13am
maybe next time you can post a little bit more code

things to check: before the SQL string gets executed, do a Response.Write of it and then a Response.End right away to manually inspect the string you build, because if you get that error, the database is telling you its wrong
Contribute to the working anarchy we fondly call the Internet
Back to Top
simflex View Drop Down
Groupie
Groupie
Avatar

Joined: 10 November 2002
Location: United States
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote simflex Quote  Post ReplyReply Direct Link To This Post Posted: 03 March 2003 at 11:58am

i did that already and my sql says there is no whereclause.

As you can see from the query, there is a whereclause which means there is something wrong with the asp code.

What am I doing wrong with this code?

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.