File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes 'Syntax Error in Query operator' MS Access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark " Watch " New topic
Author

'Syntax Error in Query operator' MS Access

pucmann pucmann
Greenhorn

Joined: Apr 28, 2003
Posts: 1
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());
}
%>
 
Don't get me started about those stupid light bulbs.
 
subject: 'Syntax Error in Query operator' MS Access