views:

44

answers:

1

I am using Microsoft Access database for storing data. In that, I stored date as "DATE/TIME" data type. While getting date from the following code it produces error..

        String sql    =   "Select prev_date from StaffAdvance where Staff_ID='"+date+"'";
        ResultSet rs  =   st.executeQuery(sql);

What is wrong with this code?

A: 

As you told the type of date object is java.util.Date, change the type to java.sql.Date and try.

GK
Yes i got it.. My friend told should use "#" instead of "'" in that query.. That isString sql = "Select prev_date from StaffAdvance where Staff_ID=#"+date+"#"; ResultSet rs = st.executeQuery(sql);
Venkats
did you change the type of date to sql.Date
GK
Yes, But i didn't got date. After changing # only it produces the result..
Venkats
The hash marks work because this is the date delimiter for Jet/ACE SQL.
David-W-Fenton