Solved

Adding a search box to a dynamic page?

Posted on 2003-11-03
5
168 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
5 Comments
 
LVL 14

Expert Comment

by:kennethxu
Comment Utility
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
Comment Utility
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
Comment Utility
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This article explains in simple steps how to renew expiring Exchange Server Internal Transport Certificate.
Veeam Backup & Replication has added a new integration – Veeam Backup for Microsoft Office 365.  In this blog, we will discuss how you can benefit from Office 365 email backup with the Veeam’s new product and try to shed some light on the needs and …
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now