毫秒的存取更新日期*例外:*如何通過NetBeans的
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement
代碼:
String Name = txtName.getText();`
String Email = txtEmail.getText();
String Mobile = txtMobile.getText();
String Address = txtAddress.getText();
String Dob = txtDob.getText();
嘗試 {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connection = DriverManager.getConnection("jdbc:odbc:NewPData");
String query = "update Table1 set Name='" + Name + "' , Email='" + Email + "' , Mobile=" + Mobile + ", Address= '" + Address
+「」,DOB =「+ Dob +」,其中ID =「+ Update; PreparedStatement ps_Statement = connection.prepareStatement(query); ps_Statement.executeUpdate(); JOptionPane.showMessageDialog(panelID,「記錄已成功更新」); connection.close(); catch(ClassNotFoundException e){ e.printStackTrace(); catch(SQLException e){ e.printStackTrace(); }
是移動,所以我沒有把單引號....出生日期我也把單引號,但得到的同樣的例外 – Shiv
你可以把一行打印查詢變量到控制檯並粘貼生成的SQL嗎?的System.out.println(查詢); – shazin
我不明白你在說什麼?和雅手機案件我得到了同樣的錯誤因爲我沒有把單引號...所以我認爲有一個問題,在我的查詢..我也已經把#DOB#但它沒有奏效 – Shiv