getstoredproccommand(“procedurename”,new object [1])在Microsoft.Practices.EnterpriseLibrary.Data.dll中抛出'System.AccessViolationException'

时间:2017-12-17 15:05:34

标签: c# .net dll oracle11g

    public static IEnumerable<PortalList> GetAll()
    {
    Database db = DatabaseFactory.CreateDatabase();
    DbCommand objComm = db.GetStoredProcCommand("package 
    name.procedurename", new object[1]);

    var result = new List<PortalList>();
    using (IDataReader rdr = db.ExecuteReader(objComm))
    {
    while (rdr.Read())
    {
      result.Add(Construct(rdr));
    }
    }
    return result;
    }

我的商店程序就像这样

PROCEDURE PRC_PROCEDURE (resultset_out OUT TYPES.cursorType)
AS
BEGIN
OPEN resultset_out FOR SELECT * FROM PORTALLISTS;
END PRC_PORTALLISTS_GETALL;

我在这一行中遇到错误DbCommand objComm = db.GetStoredProcCommand("package name.procedurename", new object[1]);

如果我这样做

DbCommand objComm = db.GetStoredProcCommand("package name.procedurename");

错误消失但我在此行中使用[Exception thrown: 'System.AccessViolationException' in Microsoft.Practices.EnterpriseLibrary.Data.dll]面临同样的错误(IDataReader rdr = db.ExecuteReader(objComm))。我使用的是dot.net framework 4和Microsoft.Practices.EnterpriseLibrary.Data.dll版本是5.0.0.0。你们能帮助我吗?

1 个答案:

答案 0 :(得分:1)

你有resultset_out作为参数,你可以通过你的参数如下

DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); 
// Output parameters specify the size of the return data.
db.AddOutParameter(dbCommand, "resultset_out", DbType.Object, Int32.MaxValue);

ref https://msdn.microsoft.com/en-us/library/ff647630.aspx