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
How can I access the enumeration OracleDbType?
提问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.
该OracleDbType是ODP:Oracle.DataAccess.Client不是弃用System.Data.OracleClient的,请尝试使用ODP并应在那里。
回答by Adam Robinson
You'll have to cast your parameter directly to an OracleParameter
to access the OracleDbType
property.
您必须将参数直接转换为 anOracleParameter
才能访问该OracleDbType
属性。