我希望我的代码根据格式验证日期,日月也应该不超过日月值......即使我输入任何格式mm/dd/yyyy或mm/dd/yyyy或yyyy/mm/dd它应该验证所有,因为 ms 访问支持所有格式。
以及如何更新它,因为我的代码是:
Connection connection;
String text = txtUpdate.getText();
int Update = Integer.parseInt(text);
String Name = txtName.getText();
String Email = txtEmail.getText();
String Mobile = txtMobile.getText();
String Address = txtAddress.getText();
String Dob = txtDob.getText();
if (check_Name() && check_Email() && check_Mobile() && check_Address() && check_Dob()) {
try {
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 + ", where ID=" + Update;
PreparedStatement ps_Statement = connection.prepareStatement(query);
ps_Statement.executeUpdate();
JOptionPane.showMessageDialog(panelID, "Record Updated Successfully");
connection.close();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}