Problem whit inserting date - Oracle and C#
-
Hi I have Date Var in Oracle, and I try to insert Data from my C# program sql = "insert into Table(MyDate) values (" + convert.todatetime(txt) + ")"; I get an Error, what can i do ?
E_Gold wrote:
I get an Error, what can i do ?
If I were you, I'd post the error here.
E_Gold wrote:
sql = "insert into Table(MyDate) values (" + convert.todatetime(txt) + ")";
Use parameters instead of concatenation[^]
Giorgi Dalakishvili #region signature My Articles Asynchronous Registry Notification Using Strongly-typed WMI Classes in .NET [^] My blog #endregion
-
Hi I have Date Var in Oracle, and I try to insert Data from my C# program sql = "insert into Table(MyDate) values (" + convert.todatetime(txt) + ")"; I get an Error, what can i do ?
-
Hi I have Date Var in Oracle, and I try to insert Data from my C# program sql = "insert into Table(MyDate) values (" + convert.todatetime(txt) + ")"; I get an Error, what can i do ?
-
Hi I have Date Var in Oracle, and I try to insert Data from my C# program sql = "insert into Table(MyDate) values (" + convert.todatetime(txt) + ")"; I get an Error, what can i do ?
- Oracle expects date to be in a certain format. If your table name is MyTable with column MyDate, use bind variables to pass values. Do this: sql = "Insert Into Mytable(MyDate) Values(:Date)"; OracleConnection conn = ... OracleCommand cmd = conn.CreateCommand(); cmd.Parameter.AddWithValue("Date", Convert.ToDateTime(txt)); ...
modified on Monday, March 30, 2009 2:44 PM
-
it will be nice if u paste ur error msg here though i find a prob with your code. I just want to be sure
It would be even nicer if you didn't use SMSSpeak to write your posts.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
- Oracle expects date to be in a certain format. If your table name is MyTable with column MyDate, use bind variables to pass values. Do this: sql = "Insert Into Mytable(MyDate) Values(:Date)"; OracleConnection conn = ... OracleCommand cmd = conn.CreateCommand(); cmd.Parameter.AddWithValue("Date", Convert.ToDateTime(txt)); ...
modified on Monday, March 30, 2009 2:44 PM
You can also use the 'TO_DATE(..)' function from Oracle SQL.