Microsoft.NET和Oracle数据访问:从类型OracleDecimal到类型String的转换无效 [英] Microsoft.NET and Oracle data access: Conversion from type OracleDecimal to type String is not valid

查看:172
本文介绍了Microsoft.NET和Oracle数据访问:从类型OracleDecimal到类型String的转换无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下ASP.NET程序,该程序调用Oracle存储过程:

I have the following ASP.NET program, which calls an Oracle stored procedure:

Dim objDBCon As New OracleConnection(strCon)
Try
    objDBCon.Open()
        Dim objDBCmd As New OracleCommand("Person.DeletePerson", objDBCon)
        objDBCmd.CommandType = CommandType.StoredProcedure

        Dim objParam As New OracleParameter
        objParam.ParameterName = "PersonID"
        objParam.OracleDbType = OracleDbType.Varchar2
        objParam.Direction = ParameterDirection.Input
        objParam.Value = PersonID
        objDBCmd.Parameters.Add(objParam)

        objParam = New OracleParameter
        objParam.ParameterName = "nReturn"
        objParam.OracleDbType = OracleDbType.Int64
        objParam.Direction = ParameterDirection.Output
        objDBCmd.Parameters.Add(objParam)

        objDBCmd.CommandTimeout = 30
        objDBCmd.ExecuteNonQuery()
        strResponse = objDBCmd.Parameters("nReturn").Value
Catch ex As Exception


Finally

'Cleanup code here

End Try

该代码在实际环境和旧开发PC上均能完美运行.但是,在我的新开发PC上,以下行引发异常:strResponse = objDBCmd.Parameters("nReturn").Value.例外是:从OracleDecimal类型转换为String类型是无效的.如果我将strResponse的数据类型更改为'Decimal',则例外是:从OracleDecimal类型转换为String类型是无效的."开发PC已安装以下文件:Windows 7,.NET Framework 3.5,Visual Studio 2008,Oracle.DataAccess版本10.2.0.100和版本2.112.1.0.我找不到有关此错误的任何信息.这是什么意思?

The code works perfectly in the live environment and on my old development PC. However, on my new development PC, an exception is thrown on the following line: strResponse = objDBCmd.Parameters("nReturn").Value. The exception is: "Conversion from type OracleDecimal to type String is not valid. If I change the data type of strResponse to 'Decimal', then the exception is: "Conversion from type OracleDecimal to type String is not valid". The development PC has the following installed: Windows 7, .NET framework 3.5, Visual Studio 2008, Oracle.DataAccess version 10.2.0.100 and version 2.112.1.0. I cannot find any information on this error. What does it mean?

更新 我在徘徊是因为我的新开发PC是64位Windows

Update I am wandering if it is because my new development pc is 64 bit windows

推荐答案

代替设置:

objParam.OracleDbType = OracleDbType.Int64

尝试:

objParam.DbType = System.Data.DbType.Int64

,您可能需要更改:

strResponse = objDBCmd.Parameters("nReturn").Value

收件人:

strResponse = objDBCmd.Parameters("nReturn").Value.ToString()

或者:

strResponse = objDBCmd.Parameters("nReturn").ToString()

这篇关于Microsoft.NET和Oracle数据访问:从类型OracleDecimal到类型String的转换无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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