Solved

Adding a search box to a dynamic page?

Posted on 2003-11-03
5
172 Views
Last Modified: 2010-04-01
What's the best methodology to use to add a wild card search box to a dynamic recordset page (without posting results to a new page).

The following code works fine:

http://sales.litehouseinc.com/EE/jsp1.txt

I want to add a search box (name = pSearch) to it that will search each/all fields for "whatever".

I was trying to do something like this:

<%
// *** Get search criteria for basic search
pSearch = Request.QueryString("psearch")
If pSearch != null
      pSearch = replace(pSearch,"'","''")
      pSearch = replace(pSearch,"[","[[]")
      b_search = b_search & "[Customer_Number] LIKE '%" & pSearch & "%' OR "
      b_search = b_search & "[Customer_Name] LIKE '%" & pSearch & "%' OR "
      b_search = b_search & "[State] LIKE '%" & pSearch & "%' OR "
      b_search = b_search & "[Phone] LIKE '%" & pSearch & "%' "
End If
%>

and test to see if it was null or not:

<%
Driver DrivermyRecordset = (Driver)Class.forName(MM_myConnection_DRIVER).newInstance();
Connection ConnmyRecordset = DriverManager.getConnection(MM_myConnection_STRING,MM_myConnection_USERNAME,MM_myConnection_PASSWORD);
{
If (pSearch != null)
  PreparedStatement StatementmyRecordset = ConnmyRecordset.prepareStatement("SELECT CUSTOMER_NUMBER, CUSTOMER_NAME, SYS_STATE, PHONE FROM FIN_TEST03.CUSTOMERS WHERE " & b_search & "ORDER BY CUSTOMER_NAME");
Else
 // regular statement from working code
  PreparedStatement StatementmyRecordset = ConnmyRecordset.prepareStatement("SELECT CUSTOMER_NUMBER, CUSTOMER_NAME, SYS_STATE, PHONE FROM FIN_TEST03.CUSTOMERS ORDER BY CUSTOMER_NAME");
}

but I gets an error(s):

Errors compiling:d:\oracle\ora817\apache\apache\htdocs\_pages\_demo\_dwtest2.java
d:\oracle\ora817\apache\apache\htdocs\_pages\_demo\_dwtest2.java:87: ';' expected.
        PreparedStatement StatementmyRecordset = ConnmyRecordset.prepareStatement("SELECT CUSTOMER_NUMBER, CUSTOMER_NAME, SYS_STATE, PHONE FROM FIN_TEST03.CUSTOMERS WHERE " & b_search & "ORDER BY CUSTOMER_NAME");
                         ^
d:\oracle\ora817\apache\apache\htdocs\_pages\_demo\_dwtest2.java:123: ';' expected.
      If pSearch != null
        ^
2 errors

Any direction?
0
Comment
Question by:globalwm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 14

Expert Comment

by:kennethxu
ID: 9675625
r u sure u r writing jsp code, it looks more like VB! you should pick a basic java/jsp book to start.
0
 
LVL 1

Author Comment

by:globalwm
ID: 9679340
The code snippit is from a working ASP page - I want to do something like that now in JSP.

I ordered a couple of JSP books - not here yet though...

0
 
LVL 14

Accepted Solution

by:
kennethxu earned 125 total points
ID: 9682114
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Justin
In light of the WannaCry ransomware attack that affected millions of Windows machines, you might wonder if your Mac needs protecting. Yes, it does and here is how to do it.
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question