Search page

Author Message
hnikou

  • Total Posts : 3
  • Scores: 0
  • Reward points : 0
  • Joined: 10/20/2007
  • Status: offline
Search page Saturday, October 20, 2007 9:24 PM (permalink)
0
I've a database with four fileds Txt1, Txt2, Pdate1 & pdate2. The two first fields are text and the others are date. I am using a search page that send Query.string to look for specific entry of Txt1 and Txt2. My question is how to show just the results dependent to appropriate pdate1 and pdate2.e.g.:I wrote the line below but no results as i needed. I want this algoritm: If( Txt1 is valid and date1 is greater than today ) OR (Txt2 is valid and date2 is greater than today )  write something. 

<% if (rs.Fields.Item("Txt1").Value) = Request.QueryString( "QueryString" ) and (rs.Fields.Item("pdate1").Value) > date()
Or  if (rs.Fields.Item("Txt2").Value) = Request.QueryString( "QueryString" ) and (rs.Fields.Item("pdate2").Value) > date() Then
Response.Write " something"
End If
rs.MoveNext
Loop
%>

Thanks in advanced.
Henry
<message edited by hnikou on Saturday, October 20, 2007 9:40 PM>
 
#1
    ehvbs

    • Total Posts : 3320
    • Scores: 110
    • Reward points : 0
    • Joined: 6/22/2005
    • Location: Germany
    • Status: offline
    RE: Search page Sunday, October 21, 2007 12:00 AM (permalink)
    0
    Hi hnikou,

    There is a syntax error in your statement:

      ... date() Or  if (rs.Field ...

    Putting brackets around a simple term like

      ... (rs.Fields.Item("Txt1").Value)

    doesn't make much sense; it would be better to bracket the subexpressions to
    avoid surprises by operator precendence:

      If ( b1 And b2 ) Or ( b3 And b4 ) Then

    You could use temporary variables to make the If expression more lucid:

      sExpectedText = Request.QueryString( "QueryString" )
      bFirstCase = rs.Fields.Item("Txt1").Value = sExpectedText 
      bFirstCase = bFirstCase And ( rs.Fields.Item("pdate1").Value > date() )
      ...
      If bFirstCase Or bSecondCase Then
      ...

    Good luck!

    ehvbs

     
    #2
      hnikou

      • Total Posts : 3
      • Scores: 0
      • Reward points : 0
      • Joined: 10/20/2007
      • Status: offline
      RE: Search page Monday, October 22, 2007 11:24 PM (permalink)
      0
      Hi ehvbs,
      Thanks alot for your comment. My problem has been solved by your comments.
      Wishes
      hnikou 
       
      #3

        Online Bookmarks Sharing: Share/Bookmark

        Jump to:

        Current active users

        There are 0 members and 1 guests.

        Icon Legend and Permission

        • New Messages
        • No New Messages
        • Hot Topic w/ New Messages
        • Hot Topic w/o New Messages
        • Locked w/ New Messages
        • Locked w/o New Messages
        • Read Message
        • Post New Thread
        • Reply to message
        • Post New Poll
        • Submit Vote
        • Post reward post
        • Delete my own posts
        • Delete my own threads
        • Rate post

        2000-2012 ASPPlayground.NET Forum Version 3.9