Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5697
  • Last Modified:

How to convert OracleDbType.Date to .net DateTime

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
karanba
Asked:
karanba
3 Solutions
 
Mohammed NasmanSoftware DeveloperCommented:
DateTime d = Convert.ToDateTime(cmd.Parameters["dateP"].Value);
0
 
ieciepCommented:
mnasman is right
DateTime d = Convert.ToDateTime(cmd.Parameters["dateP"].Value);
0
 
karanbaAuthor Commented:
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
 
RytmisCommented:
DateTime d = (DateTime) cmd.Parameters["dateP"].Value;

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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now