Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - query won’t return results
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

query won’t return results

 Post Reply Post Reply
Author
gr8indianbear View Drop Down
Groupie
Groupie


Joined: 07 November 2002
Location: United States
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote gr8indianbear Quote  Post ReplyReply Direct Link To This Post Topic: query won’t return results
    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

Back to Top
gr8indianbear View Drop Down
Groupie
Groupie


Joined: 07 November 2002
Location: United States
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote gr8indianbear Quote  Post ReplyReply Direct Link To This Post 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.



Edited by gr8indianbear
Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Phat View Drop Down
Senior Member
Senior Member


Joined: 23 February 2003
Status: Offline
Points: 386
Post Options Post Options   Thanks (0) Thanks(0)   Quote Phat Quote  Post ReplyReply Direct Link To This Post 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.


Edited by Phat
Back to Top
gr8indianbear View Drop Down
Groupie
Groupie


Joined: 07 November 2002
Location: United States
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote gr8indianbear Quote  Post ReplyReply Direct Link To This Post 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
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.