Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 29th, 2003, 02:01 AM
Registered User
 
Join Date: Jun 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem with filter form

I have created a form with the code below
<form method=get action="showfilter-sql.asp">
Enter your text here:
<input type=text name="mytext" size="20"><br>
<input type=submit value="send info">
<input type=reset>
</form>
I want to filter the records of my access db
but whatever I enter in the search field the message "There are no records that matches your search" is shown
what is the problem???????

so this page:
<%@ language=vbscript %>
<% option explicit %>

<%
dim objConn
dim objConn
set objConn=server.createobject("Adodb.connection")
objConn.ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("fpdb\satconcepts.mdb") & ";"
objConn.open
dim strMytext
strMytext=trim(request("Mytext"))
dim strSql
strSql="select term from sat where term= ' " & strMytext & "%' "
dim objRs
set objRs=server.createobject("adodb.recordset")
objrs.open strsql,objConn
if objRs.EOF then
response.write "There are no records that matches your search"
else
Do while not objRs.EOF
response.write "<b>" & objrs("term") & "</b><br>"
response.write "<b>" & objrs("definition") & "</b><br>"
objRs.movenext
loop
end if
objRs.close
set objrs=nothing
objconn.close
set objconn=nothing
%>
 
Old June 29th, 2003, 05:17 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to NotNowJohn
Default

Well,
I suppose that an error occurs here:
Code:
strSql="select term from sat where term= ' " & strMytext & "%' "
If you use "%" I suppose that you want to display all records matching the form field's value pattern, so you have to use LIKE operator instead of "=".
Code:
strSql="select term from sat where term LIKE ' " & strMytext & "%' "
Or, remove "%" if you want to display records matching exact value on the form field.

One more thing - in your SQL statement you retreive only one column named term, and objrs("definition") value cannot exist.


...but the Soon is eclipsed by the Moon





Similar Threads
Thread Thread Starter Forum Replies Last Post
Call Filter By Form bufanator Access VBA 3 November 15th, 2006 03:10 PM
Filter form with date fields problem!! chiefouko Access 2 August 14th, 2006 10:15 AM
filter a sub form ahying Access VBA 1 June 29th, 2006 04:27 AM
how to parse filter from a form to a main form flyfish Access 1 February 1st, 2005 05:36 AM
Multiple filter on a form chimp Access VBA 0 September 9th, 2004 02:59 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.