|
 |
access_asp thread: SQL Statement problem
Message #1 by "Dale James Wright" <dwright@c...> on Mon, 27 Jan 2003 14:24:27
|
|
Hi....
I have a paging page that uses users inputted text to search a database
table. The records are displayed using a paging system.....If a user
searches for say... DALE & TOM....When the user clicks on the next button
of the paging feature, the Paging system looks for JUST TOM and Not
DALE....So it is missing the search criteria...
I have a SQL statement that search the field until all words have been
accounted for....This is the Statement:
sql = "SELECT * FROM FAQAnswer WHERE "
Do Until instr
(StrSearch, " ") = 0
sql = sql & "FAQ
Like '%" _
& left
(StrSearch, instr(StrSearch," ") - 1) & "%' OR "
StrSearch = Right(StrSearch, len(StrSearch) - instr(StrSearch," "))
Loop
If len(StrSearch)
> 1 Then
sql = sql & "FAQ Like '%" & StrSearch & "%'"
Else
sql =
Left(sql, Len(sql) - 4)
End if
AND THIS IS THE PAGING LINK:
If cInt(intPage) > 1 Then
Response.Write "<td><a href=bk_searchresult.asp?
NAV=" & intPage - 1&"&FIND=" & StrSearch & "&srchType=" & Request
("srchType") & "><< Prev</a></td>"
End IF
Would love to here from anyone who knows what i am doing wrong!!!
Regards
Dale
Message #2 by "Ken Schaefer" <ken@a...> on Tue, 28 Jan 2003 15:36:50 +1100
|
|
What does your URL look like? I suspect something like this:
page.asp?Nav=1&Find=Dale&Tom
Do you see the problem? You need to use Server.URLEncode() on the *values*
you want to pass:
strNextURL = _
"page.asp" & _
"?Nav=" & Server.URLEncode(intNextPage) & _
"&Find=" & Server.URLEncode("Dale & Tom")
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Dale James Wright" <dwright@c...>
Subject: [access_asp] SQL Statement problem
: I have a paging page that uses users inputted text to search a database
: table. The records are displayed using a paging system.....If a user
: searches for say... DALE & TOM....When the user clicks on the next button
: of the paging feature, the Paging system looks for JUST TOM and Not
: DALE....So it is missing the search criteria...
:
: I have a SQL statement that search the field until all words have been
: accounted for....This is the Statement:
:
: sql = "SELECT * FROM FAQAnswer WHERE "
: Do Until instr
: (StrSearch, " ") = 0
: sql = sql & "FAQ
: Like '%" _
: & left
: (StrSearch, instr(StrSearch," ") - 1) & "%' OR "
:
: StrSearch = Right(StrSearch, len(StrSearch) - instr(StrSearch," "))
: Loop
:
: If len(StrSearch)
: > 1 Then
:
: sql = sql & "FAQ Like '%" & StrSearch & "%'"
: Else
: sql
: Left(sql, Len(sql) - 4)
: End if
:
:
: AND THIS IS THE PAGING LINK:
:
: If cInt(intPage) > 1 Then
:
: Response.Write "<td><a href=bk_searchresult.asp?
: NAV=" & intPage - 1&"&FIND=" & StrSearch & "&srchType=" & Request
: ("srchType") & "><< Prev</a></td>"
: End IF
:
:
: Would love to here from anyone who knows what i am doing wrong!!!
:
: Regards
: Dale
Message #3 by "Dale James Wright" <dwright@c...> on Tue, 28 Jan 2003 10:20:09
|
|
Now solved....Thanks for answering the question anyhows ken, regards
Dale
|
|
 |