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

问题描述 投票:1回答:1
    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]在这一行面临相同的error(IDataReader rdr = db.ExecuteReader(objComm))。我使用的是dot.net framework 4和Microsoft.Practices.EnterpriseLibrary.Data.dll版本是5.0.0.0。你们能帮助我吗?

在portallistservices.cs文件中我有这个

    public static IEnumerable<PortalList> GetAll()
    {
        return GetAll(true);
    }

    private static IEnumerable<PortalList> GetAll(bool forceDataReload)
    {
        const string cacheKey = "PortalListService_GetAll";

        IEnumerable<PortalList> result = null;

        if (!forceDataReload)
            result = GetFromCache(cacheKey);

        if (result == null)
        {
            result = PortalListRepository.GetAll();
            AddToCache(cacheKey, result);
        }

        return result;
    }
c# .net dll oracle11g
1个回答
1
投票

你有resultset_out作为param,你可以通过你的params如下

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

© www.soinside.com 2019 - 2024. All rights reserved.