Urgent Please help!!
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Chong_Lee
Posted On:   Sunday, April 21, 2002 08:33 PM

I want to insert date into database in my own format I have my code for date column. Calendar cal = Calendar.getInstance(); SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyy HH:mm"); String date = dateFormat.format(cal.getTime()); Now I want to insert date (in the Access 97 database) to execute query..the following is my insert statement..but gives error.. Statement st=con.createStatement(); String q = "INSERT into tablename (sl_number,date,name,dep_name,type) values("+ sl_number +", {date, 'dd-MM-yyyy HH:mm'}, '"+ name +"','"+ dep_name +"','"+type +"')"; st.executeUpdate(q1);    More>>

I want to insert date into database in my own format



I have my code for date column.



Calendar cal = Calendar.getInstance(); SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyy HH:mm"); String date = dateFormat.format(cal.getTime());



Now I want to insert date (in the Access 97 database) to execute query..the following is my insert statement..but gives error..



Statement st=con.createStatement(); String q = "INSERT into tablename (sl_number,date,name,dep_name,type) values("+ sl_number +", {date, 'dd-MM-yyyy HH:mm'}, '"+ name +"','"+ dep_name +"','"+type +"')"; st.executeUpdate(q1);


now I got error.pls help me..urgent..Thanks in advance.


Lee

   <<Less

Re: Urgent Please help!!

Posted By:   Anonymous  
Posted On:   Tuesday, April 23, 2002 07:16 PM

What's the error message? I think you can try to cut and paste you SQL command onto database Script tool to test whether it works or not. I think the insert syntax should go in this way
"INSERT into tablename (sl_number,date,name,dep_name,type) values("sl_number" + "," + "{date, 'dd-MM-yyyy HH:mm'}" +","+ name +","+ dep_name +","+type +")";

st.executeUpdate(q1);



Hope that helps



TC Wang
About | Sitemap | Contact