ODBC - Correct solution for passing a date field to Informix via ODBC and C#.NET
Posted in 2007
Topics: Connectivity: ODBC / JDBC / .NET, Platform-Specific Issues
Gentlemen, Thank you for your solutions. After implementing them we were still getting a syntax error from Informix. We pulled this solution off of the Microsoft ODBC website, and after trying the solution it worked successfully on the date field. This is the sql string for the Date Field Entry from C#. sql += 56 + "," + "{D '2007/09/13'}" + ","; Spyros Macris, President Philadelphia Candies, Inc. 1546 East State Street Hermitage, PA 16148 Phone: 724 981 6341 Fax: 724 981 6490 -----Original Message----- From: Mike Aubury [mailto:mike.aubury@aubit.com] Sent: Monday, September 17, 2007 2:07 PM To: informix-list@iiug.org; spyros@phillyc.com Subject: Re: ODBC Quote it... You might want to try single quotes... sql += 56 + ",'2007/09/13',"; ... On Monday 17 September 2007 18:53:19 group@phillyc.com wrote: > 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 -- Mike Aubury Aubit Computing Ltd is registered in England and Wales, Number: 3112827 Registered Address : Murlain Business Centre, Union Street, Chester, CH1 1QP __________ NOD32 2535 (20070917) Information __________ This message was checked by NOD32 antivirus system. http://www.eset.com __________ NOD32 2535 (20070917) Information __________ This message was checked by NOD32 antivirus system. http://www.eset.com