问题:
    源代码(运行的部分):String addtion = textField.getText();
System.out.println(addtion);
int addtion1=Integer.parseInt(addtion);
System.out.println(addtion1);
String user2;
user2 = LoginManager.user1;//获取LoginManager输入的user1
// System.out.println(user2);
//textField.setText(user2);
String password2;
password2=LoginManager.password1;//获取LoginManager输入的password1
//System.out.println(password2);
//textField.setText(password2);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");  
conn = DriverManager.getConnection("jdbc:odbc:atm", "", "");//连接数据库atm
ps = conn.prepareStatement("update atm set sum=sum+"+addtion1 +"where user=? and password=?");
//ps = conn.prepareStatement("update atm set sum=sum+addtion1 where user=? and password=?");
ps.setString(1,user2);
ps.setString(2,password2);
ps.executeUpdate();
conn.close();
ps.close();运行出现的错误:[Microsoft][ODBC Microsoft Access 驱动程序] 语法错误 (操作符丢失) 在查询表达式 'sum+100where user=Pa_RaM000 and password=Pa_RaM001' 中。改成下面的红色代码运行,出现错误:
 [Microsoft][ODBC Microsoft Access 驱动程序] 参数不足,期待是 3。
求解(详细的解答最好有例子),各位大侠帮帮忙!!!!
谢谢了!!!

解决方案 »

  1.   

    update atm set sum=sum+"+addtion1 +"where user=? and password=?"
    改为:
    update atm set sum=sum+"+addtion1+" where user=? and password=?"
      

  2.   

    那就是StringBuffer拼接字符串呗
      

  3.   

    那估计是ACCESS中sum=sum+"+addtion1+"这种用法的问题把sum=sum+100中的sum作为参数了加一个别名试试:update atm a set a.sum=(a.sum + "+addtion1+") where user=? and password=?" 不然就只能换种写法了。。