Oracle C#处理时间类型的Insert

首先如果直接
 
parm.Value=DateTime.Now;
 
insert into table (TheTime)Value(@parm);
 
执行sql就会报错 --------------ORA-01861: 文字与格式字符串不匹配
 
ADO.NET并没做到oracle转换。。所以oracle不兼容。
 
解决方案:
 
//先把时间转换为stirng
parm.Value=DateTime.Now.ToString("G");     
 
//Sql中调用oralce的to_date函数将string转换为Date类型
insert into table (TheTime)Value(to_date(@parm,'yy-mm-dd hh24:mi:ss'));

posted on 2014-04-28 10:16  荣锋亮  阅读(910)  评论(0编辑  收藏  举报

导航