locked
getstoredproccommand(“procedurename”,new object[1]) throws 'System.AccessViolationException' in Microsoft.Practices.EnterpriseLibrary.Data.dll RRS feed

  • Question

  • User-2062540416 posted
    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;
        }

    and my store procedure is like this

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

    i am having error in this line DbCommand objComm = db.GetStoredProcCommand("package name.procedurename", new object[1]);

    if i do this

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

    error is gone but then i am facing same error[Exception thrown: 'System.AccessViolationException' in Microsoft.Practices.EnterpriseLibrary.Data.dll] in this line using (IDataReader rdr = db.ExecuteReader(objComm)) . i am using dot.net framework 4 and Microsoft.Practices.EnterpriseLibrary.Data.dll version is 5.0.0.0. can you guys pls help me?

    and in portallistservices.cs file i have this

        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;
        }
    Monday, December 18, 2017 6:09 PM

All replies

  • User-359936451 posted

    Hello,

    Where does your data source reside in relation to your project?

    This line...

     'System.AccessViolationException'<sub></sub><sup></sup>

    indicates that you do not have the correct credentials to access the database. Is your database encrypted or password protected?

    You may need to also check system permissions.

    Wednesday, December 20, 2017 8:28 PM