RE: ODBC
Posted in 2007
Spyros- You need to treat your date values as strings for the insert: sql += 56 + ",'" + 2007/09/13 + "',"; --note the single quotes. "Insert into timeclock (tc_serial,tc_asoc_num,tc_process_num,tc_date,tc_start_time, tc_finish_time, tc_elapsed_time) values(0,9999,56,'2007/09/13',8.3,8.35,0.35)" You can also use controlchars.Quote. --EEM ________________________________________ From: informix-list-bounces@iiug.org [mailto:informix-list-bounces@iiug.org] On Behalf Of group@phillyc.com Sent: Monday, September 17, 2007 12:53 PM To: iiug Subject: ODBC We are using C# in Visual Studio 2005 to write time values to an Informix Database (Sun Solaris 2.6, Informix SE and Informix SQL Version 7.20.UD1). The following are excerpts: Statement 1: sql += 56 + "," + 2007/09/13 + ","; Table result 1 1900/01/17 ###### Statement 2 sql += 56 + "," + "2007/09/13" + ","; Actual sql string via watch value 2 "Insert into timeclock (tc_serial,tc_asoc_num,tc_process_num,tc_date,tc_start_time, tc_finish_time, tc_elapsed_time) values(0,9999,56,2007/09/13,8.3,8.35,0.35)" Table result 2 exception {"[Informix][Informix ODBC Driver][Informix]A syntax error has occurred."} System.Exception {System.Runtime.InteropServices.COMException ###### Statement 3 sql += 56 + "," + 0x22 + "2007/09/13" + 0x22 + ","; Actual sql string via watch value 3 "Insert into timeclock (tc_serial,tc_asoc_num,tc_process_num,tc_date,tc_start_time, tc_finish_time, tc_elapsed_time) values(0,9999,56,342007/09/1334,8.3,8.35,0.35)" Table result 3 exception {"[Informix][Informix ODBC Driver][Informix]A syntax error has occurred."} System.Exception {System.Runtime.InteropServices.COMException} ###### Statement 4 sql += 56 + "," + 0x22 + 2007/09/13 + 0x22 + ","; Actual sql string via watch value 4 "Insert into timeclock (tc_serial,tc_asoc_num,tc_process_num,tc_date,tc_start_time, tc_finish_time, tc_elapsed_time) values(0,9999,56,341734,8.3,8.35,0.35)" Table result 4 tc_date [2835/08/20] Any ideas on how to write this so that Informix will accept the date field? Spyros Macris, President Philadelphia Candies, Inc. 1546 East State Street Hermitage, PA 16148 Phone: 724 981 6341 Fax: 724 981 6490 Spyros Macris, President Philadelphia Candies, Inc. 1546 East State Street Hermitage, PA 16148 Phone: 724 981 6341 Fax: 724 981 6490