将DateTime从c#传递给oracle [英] Pass DateTime from c# to oracle

查看:79
本文介绍了将DateTime从c#传递给oracle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将今天的日期从C#保存到oracle,格式如下:



02/26/2013 05:58:50 PM



能否请您发送C#

解决方案

的代码,只需使用 Oracle Parameter.AddWithValue [ ^ ] - 你不应该不必要地转换数据类型,所以如果目标接受DateTime值(并且所有数据库都这样做)那么它是无意义的转换它并引入由于格式不兼容而导致错误的可能性。


你好朋友,


$ C $ b在C#你需要使用与你需要的格式一起投票你的日期



日期Time.Now.ToString(  MM / dd / yyyy hh:mm:ss tt







使用oracle时需要将其强制转换为Date,你可以在oracle中使用这种格式



  SELECT  TO_CHAR(sysdate,'  MM / dd / yyyy hh:mi:ss AM'来自


I want to save today's date from C# to oracle for the following format:

02/26/2013 05:58:50 PM

Could you please send me the code for C#

解决方案

Just pass it as a DateTime using Oracle Parameter.AddWithValue[^] - you should not convert datatypes unnecessarily, so if the target accepts DateTime values (and all DB's do) then it is pointless converting it and introducing the possibility of errors due to incompatible formats.


Hello friend,

in C# you need to cast your date using this format same as you required

DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt")




and while using oracle you need to cast it back to your Date, you can use this format in oracle

SELECT TO_CHAR(sysdate,'MM/dd/yyyy hh:mi:ss AM') from dual


这篇关于将DateTime从c#传递给oracle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆