转换OracleParameter.Value来的Int32 [英] Convert OracleParameter.Value to Int32

查看:147
本文介绍了转换OracleParameter.Value来的Int32的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储过程调用是这样的:

I have a stored procedure call that goes like this:

using (OracleConnection con = new OracleConnection(ConfigurationManager.AppSettings["Database"]))
using (OracleCommand cmd = new OracleCommand("Package.Procedure", con))
{
   Int32 existsCount;

   cmd.CommandType = CommandType.StoredProcedure;
   cmd.Parameters.Add("successCount", OracleDbType.Int32, 0, ParameterDirection.InputOutput);
   cmd.Parameters.Add("BusinessId", OracleDbType.Int64, listRec.BusinessId, ParameterDirection.Input);

    con.Open();
    cmd.ExecuteScalar();
    con.Close();

    existsCount = Convert.ToInt32(cmd.Parameters["successCount"].Value);

    return (existsCount);
}



但在这行:

But on this line:

existsCount = Convert.ToInt32(cmd.Parameters["successCount"].Value);



它抛出异常无法投类型的对象Oracle.DataAccess.Types.OracleDecimal来键入'System.IConvertible'。

It throws the Exception "Unable to cast object of type 'Oracle.DataAccess.Types.OracleDecimal' to type 'System.IConvertible'."

有什么想法?谢谢你。

推荐答案

什么

existsCount = int.Parse(cmd.Parameters["successCount"].Value.ToString());

这篇关于转换OracleParameter.Value来的Int32的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆