Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

If statement problem!!  RSS feed

 
Peter Matthews
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I'm experiencing a strange problem with my if statement. Basically, I'm wanting an error message to come up when a user does not enter a name. However at the moment, the if statement always produces the same result - even if there is no data entered into the txt field. So at the moment, all the respones from the validateText() method are "Good", even when there is no text in the text field. Any help would be very appreciated. Thanks. Pete


 
James Swan
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use .equals() to compare your Strings instead of ==
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16007
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String order = "INSERT INTO orders (name,type,capacity,voltage,quantity) " +"values ('"+ cust+"','"+ type +"','"+ capacity+"','"+voltage+ "','"+ quantity+"')";


Appending SQL statements together like that is a bad idea. You should use PreparedStatement. Look it up in the API documentation.


[ November 16, 2005: Message edited by: Jesper de Jong ]
 
Pratik Lohia
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey... cust is a string ... yu cannot use == on that. That will compare references and not the data. Use cust.equals("") instead
 
Peter Matthews
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks guys - appreciate the help!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!