【问题标题】:Is it possible to use commandType = text to call a stored procedure using System.Data.OracleClient是否可以使用 commandType = text 来调用使用 System.Data.OracleClient 的存储过程
【发布时间】:2017-09-06 15:43:13
【问题描述】:

我正在使用System.Data.OracleClient 连接到使用企业库的Oracle 数据库,我想使用commandType = Text 调用存储过程,如下所示:

Microsoft.Practices.EnterpriseLibrary.Data.Database database = null;

database = DatabaseFactory.CreateDatabase("DbInstanceName");
System.Data.Common.DbConnection conn = database.CreateConnection();

conn.Open();

commandObj = database.GetSqlStringCommand("execute procName('paramValue1','paramValue2')");
commandObj.CommandType = CommandType.Text;
commandObj.Connection = conn;

returnCode = database.ExecuteNonQuery(commandObj);

我不断收到无效的 SQL 语句错误,想知道是否可以使用 CommandType.Text 对 Oracle 进行存储过程调用。

我们不能使用CommandType = StoredProcedure,因为传入的命令字符串包括字符串中存储过程调用的所有参数值。如果这不可能,我将不得不从字符串中解析出每个参数值并将它们放入参数对象中。

【问题讨论】:

    标签: oracle enterprise-library data-access-layer oracleclient system.data.oracleclient


    【解决方案1】:

    这是可能的。我发现我的问题是“执行”语句。 Oracle 存储过程不需要此操作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-24
      • 1970-01-01
      • 1970-01-01
      • 2013-10-24
      • 2011-08-13
      相关资源
      最近更新 更多