1 Reply Latest reply on Aug 20, 2009 3:48 PM by 456311

    Convert OracleDbType.Decimal to C# decimal

      Hi all,
      Iam calling ORACLE function and I have a problem with converting OracleDbType.Decimal to System.Decimal. I have the following code:

      public decimal speed;
      OracleCommand cmd = new OracleCommand("GETNORM", dataCa.connection);
      cmd.CommandType = CommandType.StoredProcedure;
      cmd.Parameters.Add("return", OracleDbType.Int32).Direction = ParameterDirection.ReturnValue;
      cmd.Parameters.Add("CODE", OracleDbType.Decimal).Value = idSubject;
      cmd.Parameters.Add("OUTSPEED", OracleDbType.Decimal).Direction = ParameterDirection.Output;

      this.speed = (Decimal)cmd.Parameters["OUTSPEEDVALUE"].Value;

      The last line causes runtime error: Specified type-cast is invalid (I'm translating from Czech language). In VS2008 debug I see, that "cmd.Parameters["OUTSPEEDVALUE"].Value" has value (OUTSPEEDVALUE = 62).
      My question is: How can I assign value from an Oracle parameter to .NET (C#) variable.
      I'm unhappy 2 days.