Reputation: 39
I am having an error when updating my records in the takenOutTbl (only has a few records). Any help would be highly appreciated. This is the update code:
fine = overdueDays * 10; //the fine is calculated by multiplying the number of overdue days by the 10
simpleUpdate("update takenOutTbl set Random Calculations = Random Calculations " + fine);
it is connected to this method:
public static void simpleUpdate(String update) throws SQLException {
try {
Connection connection = dc.DatabaseConnection(); //a connection to the database is established
PreparedStatement statement = connection.prepareStatement(update); //the conenction is used to prepare the update statement which was sent to this method
statement.executeUpdate();//the statement is executed
statement.close(); //the prepared statement is closed
} catch (SQLException e) {
JOptionPane.showMessageDialog(null, "Error: the database was not updated. Please try again." );
System.err.print(e.getMessage());
}
}
and the error message I receive is this:
user lacks privilege or object not found: RANDOM
Upvotes: 1
Views: 34
Reputation: 97152
Correct your query as follows:
"update takenOutTbl set [Random Calculations] = [Random Calculations] + " + fine
Because of the space in your column name, you have to help out MS Access a little bit and indicate that Random Calculations
is one column. You do this by enclosing the column name in brackets.
Also, your query lacked a +
at the end, so I've added that in my example above as well.
Upvotes: 1