Print Page | Close Window

query won’t return results

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=10779
Printed Date: 31 March 2026 at 1:17pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: query won’t return results
Posted By: gr8indianbear
Subject: query won’t return results
Date Posted: 07 June 2004 at 10:33pm

I am trying to setup a simple search that will search a table in a microsoft database. here is the script i have:

     <%
     If strSection = "all" OR strSection = "" Then
      Response.Write("empty search")
     Else
      strSQL = "SELECT Beginning, Title, Blurb, Body, Author, Date "
      strSQL = strSQL & "FROM " & strSection &" "
    strSQL = strSQL & "WHERE (((Body) Like '*" & strSrchStr & "*'));"
    'If strSection = "articles" Then
       ' strSQL = strSQL & "ORDER BY Date;"
    'Else
     'strSQL = strSQL & "ORDER BY Beginning;"
    'End If
    
    
    rsCommon.open strSQL, adoCon
    
    If rsCommon.EOF Then
     Response.Write("Search for <b>" & strSrchStr & "</b> in <b>" & strSection & "</b> had no results.<br>" & strSQL )
    Else

    Response.Write("<table border=1 cellpadding=2 cellspacing=1>")
       
    Do While NOT rsCommon.EOF
    strTitle = rsCommon("Title")
    strAuthor = rsCommon("Author")
    strBlurb = rsCommon("Blurb")
    
    Response.Write( "<tr><td align=center><font size=4><b>" & strTitle & "</b></font><p></td>")
    Response.Write( "<td><i><b>" & strAuthor & "</b></i></td>" )
    Response.Write( "<td>" & Replace(strBlurb, vbCrLf, "<br />") & "</td></tr>")
    
    rsCommon.MoveNext
    
    Loop
    End If

    rsCommon.close
    
     End If
     %>

The strSQL works fine, i got it to print out. and everything is read in fine, but the rsCommon is always at EOF. why is it? the page is here:

http://www.gentlefaith.com/search.asp




Replies:
Posted By: gr8indianbear
Date Posted: 07 June 2004 at 10:34pm

i have defined rsCommon and adoCon earlier in the page before this script

ALSO: when searching the ALL ssections has been disabled for now, make sure you select a section to search in to see what i'm talking about.



Posted By: dpyers
Date Posted: 08 June 2004 at 12:53am

You didn't say what db you were using, but I don't think all of them support the * as a wildcard character. They all support % as a wildcard though.

You may want to put an rscommon.movefirst befor the first check for eof.



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Phat
Date Posted: 08 June 2004 at 12:55am
use % instead of * in the SQL

Also you get an error if you leave the search text blank

As dpyers said above.


Posted By: gr8indianbear
Date Posted: 08 June 2004 at 3:02pm
thanks for the help. it was the wildcard. using % fixed the problem. i ahve another fix i need which ill open  a new topic for



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net