gpt4 book ai didi

java - 更新我的表时出错

转载 作者:太空宇宙 更新时间:2023-11-04 06:36:26 26 4
gpt4 key购买 nike

我在更新 takeOutTbl 中的记录时遇到错误(只有几条记录)。任何帮助将不胜感激。这是更新代码:

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

它连接到这个方法:

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());
}
}

我收到的错误消息是这样的:

user lacks privilege or object not found: RANDOM

最佳答案

更正您的查询,如下所示:

"update takenOutTbl set [Random Calculations] = [Random Calculations] + " + fine

由于列名称中存在空格,您必须稍微帮助 MS Access 并指出随机计算 是一列。您可以通过将列名称括在方括号中来完成此操作。

此外,您的查询末尾缺少 +,因此我也在上面的示例中添加了它。

关于java - 更新我的表时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25320633/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com