• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

'Syntax Error in Query operator' MS Access

 
pucmann pucmann
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
I have been trying to get a solution to this problem for a while and I think i am getting close.
Basically, I'm trying to delete a record from my MS Access database where the 'Err-Date'(date/time field in format (mm/dd/yyyy)) field matches the date entered into a form by the user. Actually, my main objective is to delete all records that fall within two dates enetred by the user, but for know i'm just trying to get this to work. I beleive I am using the correct String to Date conversion syntax but i am recieveing the following error:
Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Err_Date = Sat Dec 12 00:00:00 PST 1998'.
The date should not be in the above format 'Sat Dec 12 00:00:00 PST 1998'.
Here is my code:
<%@page import="java.sql.*"%>
<%@ page import="java.text.SimpleDateFormat"%>
<%@ page import="java.util.Date"%>
<%
//define connection
Connection con = null;
try{
//get the class
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//get the connection
con = DriverManager.getConnection"jdbc dbc:errorlog", "admin", "");
}
//please catch your exceptions!
catch(Exception e){
out.println(e.getMessage());
}
%>
<%
//define resultset and statement
ResultSet rs=null;
Statement stmt=null;
try {
//Using the current database connection create a statement
stmt=con.createStatement();
String start = request.getParameter("From");//TAKEN FROM FORM
String end = request.getParameter("To");//TAKEN FROM FORM
SimpleDateFormat dateFormat = new SimpleDateFormat ("MM/dd/yyyy");
Date date = dateFormat.parse(end);
String sql="DELETE FROM tblError WHERE Err_Date = "+date+"";
rs = stmt.executeQuery(sql);
%>
<%
//close all your open resultsets, statements, and connections
rs.close();
stmt.close();
con.close();
}
//catch all your exceptions
catch (SQLException e) {
out.println(e.getMessage());
}
%>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic