Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Adding a search box to a dynamic page?

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

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
It’s time for spooky stories and consuming way too much sugar, including the many treats we’ve whipped for you in the world of tech. Check it out!
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

604 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