473,466 Members | 1,443 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

can`t use && in if statement

9 New Member
Expand|Select|Wrap|Line Numbers
  1.  
  2.  if (myDataReader.GetString(0) = empID && myDataReader.GetString(1) = shiftID && myDataReader.GetFloat(2) = Final11) 
  3.  
guyz y cant i do these??
here empID ,shiftID are originally int values in the FINALCALC table (those are the values to be expected to retrieve by myDataReader.GetString(0) n myDataReader.GetString(1)). But variable empID and shiftID are String variables which i take from two input text boxes.
Dec 18 '10 #1
4 1584
bentleyw
32 New Member
I think maybe it's because of the '=' instead of '=='. If you are indeed trying to compare each value, give this a try instead:
Expand|Select|Wrap|Line Numbers
  1. if ((myDataReader.GetString(0) == empID) && (myDataReader.GetString(1) == shiftID) && (myDataReader.GetFloat(2) == Final11))
Dec 18 '10 #2
Subin Ninan
91 New Member
You need to use "==" operator to check for equality. "=" operator is used to assign values.
Also, you need to group conditions in parenthesis "(a>b)&&(b>c)" to use logical operators like !, &, |, &&, ||,etc..
Expand|Select|Wrap|Line Numbers
  1. if ((myDataReader.GetString(0) == empID) && (myDataReader.GetString(1) == shiftID) && (myDataReader.GetFloat(2) == Final11))
  2. {}
  3.  
Dec 19 '10 #3
isitha
9 New Member
guyz sry 4 da late reply,

bentley :- thanx 4 ur help and i saw ur dock test article n downloaded ur examples...hope 2 use them in my projects....and also i gonna report microsoft abt U....suspect 4 software crimes...ha! ha! [i jst kidding]

@subin :- thnx guy it workd pretty nice...n thnx agn 4 accepting my frnd req.
Dec 19 '10 #4
HaLo2FrEeEk
404 Contributor
You sound extremely uneducated and immature when replying like you have. You might have gotten help with this problem, but in the future, most people will simply ignore your question entirely when they see sentences like:

"guyz sry 4 da late reply"

And

"thnx guy it worked pretty nice...n thnx agn 4 accepting my frnd req."

Do you realize that out of the 14 words in that second sentence, half of them are spelled incorrectly? If you want to be taken seriously, try using proper grammar, spelling, and punctuation in your postings.
Dec 23 '10 #5

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

Similar topics

3
by: Stefan Weiss | last post by:
Hi. function printx($str) { echo $str; } true && printx("foo"); true && print("bar");
1
by: charles | last post by:
when i read the notable book of inside the c++ bject model ,i was confused by the chapter 3.3. i was confused by the statement as follow: chaper 3.3: Given the following pair of program...
14
by: hokus | last post by:
Jak zapisać pętlę for, aby po każdej iteracji zmienna i1 zwiększała się o 2, a i2 o 4. Dzięki
17
by: orekinbck | last post by:
Hi There Say I want to check if object1.Property1 is equal to a value, but object1 could be null. At the moment I have code like this: if (object1 != null) { if (object1.Property ==...
8
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);"...
11
by: Jeremy | last post by:
How can one stop a browser from converting &amp; to & ? We have a textarea in our system wehre a user can type in some html code and have it saved to the database. When the data is retireved...
14
by: Arne | last post by:
A lot of Firefox users I know, says they have problems with validation where the ampersand sign has to be written as &amp; to be valid. I don't have Firefox my self and don't wont to install it only...
14
by: mdh | last post by:
One of the things I have yet to fully grasp ( of many things) is when to use, for example if (c !=b || c !=e || c !=f)....etc versus if ( (c !=b && c !=e && c !=f) What is the real...
9
by: John | last post by:
Hello all. I am a PHP newbie and am having an issue using the && in an if statement. here is the code: if ($_REQUEST == "1" && date("Y-m-d") < $rowWork) { die("<h1>The earlybird special has...
7
by: Charles Law | last post by:
This is a very basic question, but I can' turn up a statement on the subject: In C#, if I have If (x == 1 && y == 2) { .... }
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.