Skip to Content
0
Former Member
Dec 15, 2006 at 09:30 AM

error with date field when inserting records into sql server from webdynpro

36 Views

Dear SDN's,

I am trying to insert the records into sql server through my webDynpro program.

I have created a date field in a dictionary with the datatype date.

In my webdynpro program to insert the date i am following the below format.

String dateString = "2006/12/10";

java.util.Date d=new java.util.Date(dateString);

java.sql.Date <b>date</b> = new java.sql.Date(d.getTime());

int i=stmt.executeUpdate("INSERT INTO TRAVEL_HEADER(TRQID,PROJECTID,<b>REQDT</b>,ADVCE,ETADV,PURTR) values(21, '555-1212', '" + <b>date</b> + "', 5000, '20060501','hi')");

when i try to execute it, it gives the following error.

<b>com.sap.sql.log.OpenSQLException: The SQL statement "INSERT INTO "TRAVEL_HEADER" ("TRQID","PROJECTID","REQDT","ADVCE","ETADV","PURTR") VALUES (21,'555-1212','2006-12-10',5000,'20060501','hi')" contains the semantics error[s]: - type check error: new value (element number 3 (CHAR)) is not assignable to column >>REQDT<< (DATE)</b>

Please correct me.

Your help will be appreciated.

Regards,

Sireesha.B