Oracle Error: Unable to cast object of type Oracle.DataAccess.Types.OracleDate to type System.IConvertible RRS feed

  • Question

  • User1424746682 posted

    I'm getting the following error when I try to convert an OracleParameter Date field to a .net Datetime field.
    {"Unable to cast object of type 'Oracle.DataAccess.Types.OracleDate' to type 'System.IConvertible'."} System.InvalidCastException.
    I've included snipets of the code.  The stored procedure it calls is working OK. I can bind it to a gridview without a problem.  What I can't do it take the return value and convert it into a .net DateTime field. I tried to convert it to a string but that only returns the date portion of the field - I need the time as well. Ultimately, I want the field to be tied to a calendar control.  All help appreciated. Thanks.

    OracleParameter oraParmGet_START_DATE_OUT = new OracleParameter();
    oraParmGet_START_DATE_OUT.ParameterName = "START_DATE_OUT";
    oraParmGet_START_DATE_OUT.OracleDbType =
    oraParmGet_START_DATE_OUT.Direction =
    oraParmGet_START_DATE_OUT.Size = 38;
    DateTime startDate = Convert.ToDateTime(oraParmGet_START_DATE_OUT.Value);



    Tuesday, April 29, 2008 11:35 AM

All replies

  • User1349123926 posted

    This should work I think... 

    DateTime startDate = (DateTime)(OracleDate)oraParmGet_START_DATE_OUT.Value;


    Hope it helps,

    Tuesday, April 29, 2008 1:51 PM
  • User1424746682 posted

    That worked. Thanks.


    Tuesday, April 29, 2008 2:29 PM
  • User1988518825 posted

    Excelent! Thanks a lot! 

    Friday, September 19, 2014 4:10 PM