Solved

Adding a search box to a dynamic page?

Posted on 2003-11-03
5
169 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
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to group array of objects ? 5 65
'exit' is not valid keyword in java 14 152
struts hibernate integration example 28 133
spring JDBC Template example error 26 240
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
Each year, investment in cloud platforms grows more than 20% (https://www.immun.io/hubfs/Immunio_2016/Content/Marketing/Cloud-Security-Report-2016.pdf?submissionGuid=a8d80a00-6fee-4b85-81db-a4e28f681762) as an increasing number of companies begin to…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

770 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