dcsimg
how can i insert my input date value from a html file and insert into MSaccess 2000 database?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   a_b
Posted On:   Friday, February 8, 2002 10:56 PM

I have try to capture values e.g 1999/12/12 from a html files and pass to a jsp files and convert it into following : java.sql.Date adate = Date.valueOf(req.getparameter("date")); and put the "adate" into a SQL statement , but it show argument type mismatch when i try to insert it into Access 2000 database, is that any things i did wrong ? the following is my INSERT SQL statement : Insert into table1 (date) values(#adate#); i hear that some ppl say use java.util.date is also ok to insert date object into access2000 date column? is that right? how can i convert it? is anyone know ,pls reply as soon as possible? thx a lot    More>>

I have try to capture values e.g 1999/12/12 from a html files and pass to a jsp files and convert it into following :


java.sql.Date adate = Date.valueOf(req.getparameter("date"));


and put the "adate" into a SQL statement , but it show argument type mismatch when i try to insert it into Access 2000 database, is that any things i did wrong ? the following is my INSERT SQL statement :


Insert into table1 (date) values(#adate#);


i hear that some ppl say use java.util.date is also ok to insert date object into access2000 date column? is that right? how can i convert it? is anyone know ,pls reply as soon as possible? thx a lot

   <<Less

Re: how can i insert my input date value from a html file and insert into MSaccess 2000 database?

Posted By:   Srikant_Gudi  
Posted On:   Saturday, February 9, 2002 12:47 AM

First of all, enter your input value in the format 'yyyy-MM-dd'.

Next try the following:


java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd");

java.sql.Date adate = df.parse((req.getparameter("date"), new ParsePosition(0));

// use PreparedStatement to do the insert:


PreparedStatement ps = con.prepareStatement("INSERT INTO table1 (date) values (?)");
ps.setDate(1,adate);
ps.executeUpdate();


I hope this solves your problem !

About | Sitemap | Contact