473,385 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

problem with if else!!

53
hi all

i have a problem with my code.following is my code:



[Codes]

Connection con = null;
PreparedStatement stmt = null;
ResultSet rs = null;
Map resultMap = null;
List result = null;
String sql="";


try{
con = Utilities.getDbConnection();

sql="select * from tran_event where tran_event_cd is not null";

if (chk1.equals("Y") && !eventCd.equals("null")){

sql=sql + " AND event_cd='"+eventCd+"'";
System.out.println("anything...eventcode.......... "+sql);
}
/* else
{
sql=sql;
}*/


if
(chk2.equals("Y") && !partyCd.equals("null")){
sql=sql + " AND party_cd='"+partyCd+"'";
System.out.println("anything...partyCode.......... "+sql);
}
/*else
{
sql=sql;
}*/

if
(chk3.equals("Y") && projectCd!="null"){
sql=sql + " AND project_cd='"+projectCd+"'";
System.out.println("anything...projectcode........ .."+sql);
}
/* else
{
sql=sql;
}*/
if
(chk4.equals("Y") && fromDt!="null" && toDt!="null"){
sql=sql + " AND event_dt between '"+fromDt+"' and '"+toDt+"'";

}
/* else
{
sql=sql;
}*/
stmt = con.prepareStatement(sql);
System.out.println("check"+ stmt);


rs = stmt.executeQuery();
[/Codes]

my problem is that i need my sql statement to enter in each of the specified if condition. if the condition doesn't meet the requirement then the sql statement should be added to the next condition that meets the requirement.
but my code only meets to that condition where the sql statement is placed just with that condition.

so please help me

thanks in advance
Jul 22 '07 #1
1 1416
JosAH
11,448 Expert 8TB
Expand|Select|Wrap|Line Numbers
  1. if (chk1.equals("Y") && !eventCd.equals("null")){
  2. if (chk3.equals("Y") &&  projectCd!="null"){
  3.  
I took two sample lines from your method; the first line correctly checks two
strings for equality; the second line doesn't. Can you see the difference? There
are more incorrect lines like that.

btw, I notices you tried to tag your source code. The tag name is 'code', not 'codes'.

kind regards,

Jos
Jul 22 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: newbie_mw | last post by:
Hi, I need urgent help with a novice problem. I would appreciate any advice, suggestions... Thanks a lot in advance! Here it is: I created a sign-up sheet (reg.html) where people fill in their...
5
by: Wm | last post by:
I'm not sure why this isn't working, but it's giving me no output. I have a form which requests email and city to pull up a listing, then Email that address with their password. I'm doing an...
4
by: JesusFreak | last post by:
From: us_traveller@yahoo.com (JesusFreak) Newsgroups: microsoft.public.scripting.jscript Subject: toolbar script problem NNTP-Posting-Host: 192.92.126.136 Recently, I downloaded the following...
2
by: Tim Simmons | last post by:
I am stumped. I encoded the action = of my form using GET and I can't seem to get the property/value stuff from it using a JavaScript script I got from the web. I want to create a trivia game...
2
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c...
18
by: len.hartley | last post by:
Hi, I am trying to pop-up a window when the user clicks on an image. The problem is that when the user clicks on the image and the window pops up OK, but the window underneath also proceeds to...
1
by: Nacho | last post by:
Hello.. I have one problem with my reusable function to validate date.. I want to use this function to all my web project no validate date, but It's works fine if I have one textbox to...
7
by: Kamal | last post by:
Hello all, I have a very simple html table with collapsible rows and sorting capabilities. The collapsible row is hidden with css rule (display:none). When one clicks in the left of the...
9
by: sunita jadhav | last post by:
my question is if i type in html textbox on key press event suppose i type 12345 values in textbox then i delete or edit any value of text box suppose i edit 3 and i insert the value 6 at 3 but i...
11
by: jessy | last post by:
Hi, I have a problem with my DateTimePicker javascript code which i downloaded , the problem is when i pick the date and the date appears in my Text Field and i click Submit the date which i picked...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.