C# – How to insert date in an Oracle relational database using C#

c++odacoracle

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 ?

Best Solution

cmd.CommandText = "INSERT INTO Table (myDate)VALUES(:dateParam)";

cmd.Parameters.Add(new OracleParameter("dateParam", OracleDbType.Date))
    .Value = DateTime.Now;

cmd.ExecuteNonQuery();