This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with sql update command ->

 
Dominic Steng�rd
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there!
I am trying to update a table in my access database, the code in my bean for doing this is:
// Create the statement object -->
Statement statement = connection.createStatement();
// Define and execute the sql update -->
String update = "UPDATE user SET FNAME="+fName+",LNAME="+lName+",USERID="+userId+",PASSWORD="+password+" WHERE FNAME="+user;
statement.executeUpdate(update);
I get no errors so I thought everything was working just fine, but when I took a look in the database, no changes had been made... any suggestions to what is happening? Is the code above wrong?
Thanks in advance!
Regards
------------------
Dominic Steng�rd
Sun Certified Java 2 Programmer
------------------

[This message has been edited by Dominic Steng�rd (edited April 21, 2001).]
 
prabhat kumar
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
u need to pass the string(varchar) values in quotes
like
"where fname='"+fname+"' and rest of the query like this"
hope it will help
 
Dominic Steng�rd
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks prabhat!
That fixed my problem.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!