aspose file tools*
The moose likes JDBC 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
Bookmark "Help with sql update command ->" Watch "Help with sql update command ->" New topic
Author

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;
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).]


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
like
"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: http://aspose.com/file-tools
 
subject: Help with sql update command ->