File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Help with sql update command -> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Help with sql update command ->" Watch "Help with sql update command ->" New topic

Help with sql update command ->

Dominic Steng�rd
Ranch Hand

Joined: Feb 05, 2001
Posts: 186
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;
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!
Dominic Steng�rd
Sun Certified Java 2 Programmer

[This message has been edited by Dominic Steng�rd (edited April 21, 2001).]

Dominic Steng�rd<br />Sun Certified Java 2 Programmer
prabhat kumar
Ranch Hand

Joined: Apr 11, 2001
Posts: 114
u need to pass the string(varchar) values in quotes
"where fname='"+fname+"' and rest of the query like this"
hope it will help
Dominic Steng�rd
Ranch Hand

Joined: Feb 05, 2001
Posts: 186
Thanks prabhat!
That fixed my problem.
I agree. Here's the link:
subject: Help with sql update command ->
It's not a secret anymore!