DB_Connect di=new DB_Connect();//数据库连接
int num=-1;
di.rs=di.stmt.executeQuery( "select *from Debt ");
while(di.rs.next())
{
num=num+1;
}
String s1=jf1.getText();
java.sql.Date a=java.sql.Date.valueOf(s1);
String s2=jf2.getText();
String s3=jf3.getText();
double d=Double.parseDouble(s2);
System.out.println(num);
if(num!=-1)
{
System.out.println( "update Debt set Date= ' "+a+ " ',Money= "+d+ ",Currency= ' "+s3+ " ' where Id= "+num+ " ");
di.stmt.executeUpdate( "update Debt set Date= ' "+a+ " ',Money= "+d+ ",Currency= ' "+s3+ " ' where Id= "+num+ " ");
}
报错:
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] UPDATE 语句的语
法错误。
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3111)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(JdbcOdbcStatement.java:
288)
请大家帮帮忙啊
------解决方法--------------------------------------------------------
di.stmt.executeUpdate( "update Debt set Date= ' "+a+ " ',Money= "+d+ ",Currency= ' "+s3+ " ' where Id= "+num+ " ");
========================================
弄到sql查询分析器里面,一看就知道你的错误在哪里。
------解决方法--------------------------------------------------------
是生成的SQL语法错误,注意你的参数类型,int型是不用引号的
------解决方法--------------------------------------------------------
没有createStatement()方法