Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Adding a search box to a dynamic page?

Posted on 2003-11-03
5
Medium Priority
?
175 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
  • 2
3 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 500 total points
ID: 9682114
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Ready to kick start your career in 2018? Add app developer skills to your resume. January’s Course of the Month features Android App Development training with hands-on learning.  Read on to learn why these skills are important.
As a matter of fact, Outlook OST files are of much importance in relation to Exchange mailbox. OST files are independent as they are simply copy of data of a user’s mailbox on Exchange Server. Though, if the server’s status is changed or it is dama…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

571 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