Solved

How to convert OracleDbType.Date to .net DateTime

Posted on 2007-04-05
4
4,823 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:mnasman
mnasman earned 100 total points
Comment Utility
DateTime d = Convert.ToDateTime(cmd.Parameters["dateP"].Value);
0
 
LVL 3

Assisted Solution

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

Author Comment

by:karanba
Comment Utility
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
Comment Utility
DateTime d = (DateTime) cmd.Parameters["dateP"].Value;

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

16 Experts available now in Live!

Get 1:1 Help Now