Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: ASP Access Advanced Search

  1. #11
    Join Date
    Jun 2005
    Posts
    1,080
    Thanks
    4
    Thanked 15 Times in 15 Posts

    Default

    [see above - duplicated post by accident]
    Last edited by Sol; 12th June 2008 at 11:27 AM. Reason: Duplicated post - trimmed to remove excess text

  2. #12
    Join Date
    Jun 2005
    Posts
    1,080
    Thanks
    4
    Thanked 15 Times in 15 Posts

    Default

    I don't think you can specify a column name as a parameter, which is what Alistair has done:

    Code:
    rsSpec__MMWall = "0"
    If (Request.Form("txt_thickness")    <> "") Then 
      rsSpec__MMWall = Request.Form("txt_thickness")   
      strQuery = strQuery + " AND ? BETWEEN wp_wt_from AND wp_wt_to"
    End If
    I think you should look to do something like:

    Code:
    If (Request.Form("txt_thickness_from") <> "") then
      If (Request.Form("txt_thickness_to") <> "") then
         strQuery = strQuery + "AND [thicknessCol] BETWEEN ? AND ?"
      Else
         strQuery = strQuery + "AND [thicknessCol] >= ?"
      End If
    Else
      If (Request.Form("txt_thickness_to") <> "") then
         strQuery = strQuery + "AND [thicknessCol] <= ?"
      End If
    End If
    note: You should replace [thicknessCol] with the column name that stores the items thickness.

  3. #13
    Join Date
    Feb 2005
    Posts
    81
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    I am still having trouble with this getting the same error

    Any chace that someone could post a working page with test details???

    To recap I want 2 dropdowns and 2 text fields.

    All the search criteria must work independently of each other when left blank.

    Many thanks,

    Stephen

  4. #14
    Join Date
    May 2007
    Location
    Eauze, France
    Posts
    175
    Thanks
    10
    Thanked 17 Times in 15 Posts

    Default

    Quote Originally Posted by s80wkr View Post
    I am still having trouble with this getting the same error

    Any chace that someone could post a working page with test details???

    To recap I want .

    All the search criteria must work independently of each other when left blank.

    Many thanks,

    Stephen
    O.K. - can you explain how you get to the between values with "2 dropdowns and 2 text fields"

    David.

  5. #15
    Join Date
    Feb 2005
    Posts
    81
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    Entered into the database there are seven fields

    ID
    Specification
    Grade
    Wall Thickness from (2 decimal places)
    Wall Thickness to (2 decimal places)
    Pipe Diameter from (2 decimal places)
    Pipe Diamter to (2 decimal places)

    Specification and Grade are your 2 dropdowns populated by a DISTINCT statements for Specification and Grade taken from the database.

    The two text fields are for Wall Thickness and Pipe Diameter

    The value that is given in the Wall Thickness text box has to be between these two values Wall Thickness from and Wall Thickness To

    The same applies for Pipe Diameter.

    Many thanks for your help


  6. #16
    Join Date
    May 2007
    Location
    Eauze, France
    Posts
    175
    Thanks
    10
    Thanked 17 Times in 15 Posts

    Default

    Try the following:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta content="text/html; charset=windows-1252" http-equiv="Content-Type" />
    <title>Untitled 1</title>
    </head>
    <body>
    <!-- METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" -->
    <!-- #include virtual = "/DB.inc" -->
    <%'Connection String is defined in above include
    If lcase(Request.ServerVariables("REQUEST_METHOD")) = "post" Then
    Set Cnxn = Server.CreateObject("ADODB.Connection")
    Cnxn.Open Connect
    strQuery = "SELECT * FROM Dave.qry_weld_pro WHERE specification = ? AND grade = ?"

    Set rsSpec_cmd = Server.CreateObject("ADODB.Command")
    rsSpec_cmd.CommandType = adCmdText
    rsSpec_cmd.ActiveConnection = Cnxn

    Set P1=rsSpec_cmd.CreateParameter(, adVarChar, AdParamInput, 50, Request.Form("mnu_spec"))
    rsSpec_cmd.Parameters.Append P1
    Set P2=rsSpec_cmd.CreateParameter(, adVarChar, AdParamInput, 50, Request.Form("txt_type"))
    rsSpec_cmd.Parameters.Append P2

    If Request.Form("txt_thickness") <> "" Then
    rsSpec__MMColParam3 = Request.Form("txt_thickness")
    strQuery = strQuery & " AND Wall_Thickness_from <= ? AND Wall_Thickness_to >=?"
    Set P3=rsSpec_cmd.CreateParameter(, adDouble, AdParamInput, 20, Request.Form("txt_thickness")) ' adDouble
    rsSpec_cmd.Parameters.Append P3
    Set P4=rsSpec_cmd.CreateParameter(, adDouble, AdParamInput, 20, Request.Form("txt_thickness")) ' adDouble
    rsSpec_cmd.Parameters.Append P4
    End If
    If (Request.Form("txt_diameter") <> "") Then
    strQuery = strQuery + " AND Pipe_Diameter_from <= ? And Pipe_Diameter_to >=?"
    Set P5=rsSpec_cmd.CreateParameter(, adDouble, AdParamInput, 20, Request.Form("txt_diameter")) ' adDouble
    rsSpec_cmd.Parameters.Append P5
    Set P6=rsSpec_cmd.CreateParameter(, adDouble, AdParamInput, 20, Request.Form("txt_diameter")) ' adDouble
    rsSpec_cmd.Parameters.Append P6
    End If
    rsSpec_cmd.Prepared = true
    rsSpec_cmd.CommandText = strQuery

    Set RS1 = Server.CreateObject("ADODB.Recordset")
    Rs1.CursorType = 1
    Rs1.CursorLocation = 3
    Rs1.LockType = 3
    RS1.Open rsSpec_cmd
    If NOT Rs1.Eof Then%><table border="1">
    <% Do until Rs1.EOF%>
    <tr><td><%=Rs1("Specification")%></td><td><%=Rs1("Grade")%></td><td><%=Rs1("Wall_Thickness_from")%></td><td><%=Rs1("Wall_Thickness_to")%></td><td><%=Rs1("Pipe_Diameter_from")%></td><td><%=Rs1("Pipe_Diameter_to")%></td></tr>
    <%Rs1.MoveNext
    Loop%>
    </table>
    <%End If
    Else%>
    <form action="/Test/Test.asp" method="post">
    Specification: <select name="mnu_spec">
    <option>AAAAAA</option>
    <option>BBBBBB</option>
    </select><br />
    Grade: <select name="txt_type">
    <option>A</option>
    <option>B</option>
    </select><br />
    Wall Thickness <input name="txt_thickness" type="text" />Diameter
    <input name="txt_diameter" type="text" /><input type="submit" name="S1"/></form>
    &nbsp;<%End If
    %>
    </body>
    </html>

    You can find my crude example at: http://bookholidayrentals.com/Test/Test.asp

    Assumptions: In the Database To's are >= From's
    Validation needed for numeric fields
    It's raining here in what should be sunny France.

    I have used a recordset as this would be a good structure (I think) for an update script (and I like them).

    Good luck,
    David.

    Test Data:
    1AAAAAAA1.002.003.004.002AAAAAAA1.202.802.005.003B BBBBBA0.608.003.004.004BBBBBBB0.4020.003.2020.005A AAAAAA0.4019.001.0030.00

  7. #17
    Join Date
    Feb 2005
    Posts
    81
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    Thank very much

    Your help is very much appreciated

    Hopefully I can bash it into the db



    Ste

  8. #18
    Join Date
    May 2007
    Location
    Eauze, France
    Posts
    175
    Thanks
    10
    Thanked 17 Times in 15 Posts

    Default

    What field is the content box?
    If it is a numeric parameter then you need to validate it first, In this case I would suggest by JavaScript.

  9. #19
    Join Date
    Mar 2005
    Location
    Isle of Man
    Posts
    1,261
    Thanks
    3
    Thanked 23 Times in 23 Posts

    Default

    Looks to me like you're not escaping the input from the content field.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. search function question with asp
    By HostCan in forum ASP (VBScript)
    Replies: 5
    Last Post: 31st March 2008, 08:02 PM
  2. ASP.NET Search Engine
    By Furzetech in forum ASP.NET
    Replies: 1
    Last Post: 1st June 2007, 06:31 PM
  3. Search engine friendly pages ASP
    By philplatt in forum SEO and Website Promotion
    Replies: 15
    Last Post: 15th February 2006, 10:17 PM
  4. Access ASP Problem
    By s80wkr in forum ASP (VBScript)
    Replies: 9
    Last Post: 9th September 2005, 03:23 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •