Excecuting Update Statements

M

morc

hey im having a little bit of trouble excecuting my update statsments.
I chekd in access directly and am sure that there is no errors in my
SQL.

this is the code i used. The connection is fine its been tested before.



String remove = "UPDATE items SET qty = qty - 1 WHERE store =
'"+from+"' and barcode ='"+barcode+"'";


Statement stmt = null;


try {
stmt = conn01.createStatement();
stmt.executeUpdate(remove);
} catch (SQLException e) {
e.printStackTrace();
}


If anyone knows what the error is it would be greatly appreciated.
thanks
-morc
 
O

Oliver Wong

morc said:
hey im having a little bit of trouble excecuting my update statsments.
I chekd in access directly and am sure that there is no errors in my
SQL.

this is the code i used. The connection is fine its been tested before.



String remove = "UPDATE items SET qty = qty - 1 WHERE store =
'"+from+"' and barcode ='"+barcode+"'";


Statement stmt = null;


try {
stmt = conn01.createStatement();
stmt.executeUpdate(remove);
} catch (SQLException e) {
e.printStackTrace();
}


If anyone knows what the error is it would be greatly appreciated.
thanks

See
http://riters.com/JINX/index.cgi/Su...estions_20on_20Newsgroups#RepeatErrorsExactly

Also, you're leaving yourself vulnerable to SQL injection attacks. See
http://nebupookins.net/entry.php?id=334 You'll probably want to google for
"Prepared Statements".

- Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,128
Latest member
ElwoodPhil
Top