oracle 如何访问枚举 OracleDbType?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4970930/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 22:44:31  来源:igfitidea点击:

How can I access the enumeration OracleDbType?

c#oracle

提问by xbonez

My C# (.NET 4.0) application is calling a stored procedure in a PL/SQL database. I have added the namespace System.Data.OracleClient, and added the parameters however whenever I run it, I get an exception saying parameters don't match.

我的 C# (.NET 4.0) 应用程序正在调用 PL/SQL 数据库中的存储过程。我添加了命名空间 System.Data.OracleClient,并添加了参数,但是每当我运行它时,我都会收到一个异常,说参数不匹配。

I believe the issue is because my parameters have been of type DbType.String or OracleType.VarChar. Reading online revealed that people use another enumeration called OracleDbType (eg. OracleDbType.VarChar2).

我相信这个问题是因为我的参数是 DbType.String 或 OracleType.VarChar 类型。在线阅读发现人们使用另一种称为 OracleDbType 的枚举(例如 OracleDbType.VarChar2)。

So, how can I access this enumeration?

那么,我怎样才能访问这个枚举呢?

 OracleParameter returnParam = new OracleParameter("result", DbType.Xml);
            returnParam.Direction = ParameterDirection.ReturnValue;
            objCmd.Parameters.Add(returnParam);

            OracleParameter param1 = new OracleParameter("pivequivalentinstrument", DbType.String);
            param1.Direction = ParameterDirection.Input;
            param1.Value = EquivalentInstrKey;
            objCmd.Parameters.Add(param1);

回答by Harrison

The OracleDbTypeis ODP: Oracle.DataAccess.Clientnot the deprecated System.Data.OracleClient, try using ODP and it shall be there.

OracleDbTypeODP:Oracle.DataAccess.Client不是弃用System.Data.OracleClient的,请尝试使用ODP并应在那里。

回答by Adam Robinson

You'll have to cast your parameter directly to an OracleParameterto access the OracleDbTypeproperty.

您必须将参数直接转换为 anOracleParameter才能访问该OracleDbType属性。