0
PreparedStatement update = con.prepareStatement(
    "UPDATE employee SET FirstName = ?, LastName = ?, HighestDegreeEarned = ?, JoiningDate = ?, CurrentPost = ?, DeparmentID = ?, ContactNo(Mobile) = ?, ContactNo(Home) = ?, CurrentAddress = ?, PermanentAddress = ? WHERE ID =  ?");

update.setString(1, firstnametxt.getText());
update.setString(2, lastnametxt.getText());
update.setString(3, degreetxt.getText());
update.setString(4, joiningdatetxt.getText());
update.setString(5, currentposttxt.getText());
update.setString(6, departmentidtxt.getText());
update.setString(7, mobiletxt.getText());
update.setString(8, contactnotxt.getText());
update.setString(9, currentaddresstxt.getText());
update.setString(10, permanentaddresstxt.getText());
update.setString(11, empidtxt.getText());

update.executeUpdate();

这是代码,在执行时我得到了下面的错误。SQL 异常:java.sql.SQLException:[Microsoft][ODBC SQL Server Driver][SQL Server]')' 附近的语法不正确。请帮助我

4

2 回答 2

0

无法命名数据库中的列:ContactNo(Mobile) 或 ContactNo(Home)

如果 ContactNo() 是一个函数,使用动态 sql 调用它。

于 2013-03-13T10:50:51.253 回答
0

失败可能有两个原因

  1. SQL server 中的 ContactNo 函数未退出或未编译
  2. JoiningDate 格式不正确
于 2013-03-13T10:56:42.963 回答