Solved

How to convert OracleDbType.Date to .net DateTime

Posted on 2007-04-05
4
4,981 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

777 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