Solved

How to convert OracleDbType.Date to .net DateTime

Posted on 2007-04-05
4
4,903 Views
Last Modified: 2008-03-04
Hi,
I want to convert OracleDbType.Date to .net DateTime.

OracleParameter param1 = new OracleParameter("dateP", OracleDbType.Date);
param1.Direction = System.Data.ParameterDirection.Output;
cmd.Parameters.Add(param1);
cmd.ExecuteNonQuery();

---> ?  DateTime d = cmd.Parameters["dateP"].Value

And a second question does the given parameter name in OracleParameter  must be the same with defined in procedure?
0
Comment
Question by:karanba
4 Comments
 
LVL 22

Assisted Solution

by:Mohammed Nasman
Mohammed Nasman earned 100 total points
ID: 18856528
DateTime d = Convert.ToDateTime(cmd.Parameters["dateP"].Value);
0
 
LVL 3

Assisted Solution

by:ieciep
ieciep earned 200 total points
ID: 18856595
mnasman is right
DateTime d = Convert.ToDateTime(cmd.Parameters["dateP"].Value);
0
 

Author Comment

by:karanba
ID: 18856618
DateTime d = Convert.ToDateTime(cmd.Parameters["dateP"].Value);

that gives the following error.

Unable to cast object of type 'Oracle.DataAccess.Types.OracleDate' to type 'System.IConvertible'.
0
 
LVL 8

Accepted Solution

by:
Rytmis earned 200 total points
ID: 18856762
DateTime d = (DateTime) cmd.Parameters["dateP"].Value;

(According to the ODP.NET docs, OracleDate defines an explicit conversion to a DateTime)
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now