locked
ExecuteReader error (Microsoft Enterprise Libraries) RRS feed

  • Question

  • User-1687586234 posted
    Hi, I try the following code in my application Database db = DatabaseFactory.CreateDatabase("vhGallery"); DBCommandWrapper cmd = db.GetStoredProcCommandWrapper("vhGallery_GetAlbum"); cmd.AddInParameter("AlbumID", DbType.Int32, this.AlbumID); IDataReader dr = null; try { dr = db.ExecuteReader(cmd); if(dr.Read()) { this.AlbumName = (string)dr["AlbumName"]; this.AlbumParentID = (int)dr["AlbumParentID"]; this.AlbumBrief = (string)dr["AlbumBrief"]; this.AlbumLastChange = (DateTime)dr["AlbumLastChange"]; this.AlbumPictureCount = (int)dr["AlbumPictureCount"]; this.AlbumSubAlbumCount = (int)dr["AlbumSubAlbumCount"]; this.AlbumHighlightPictureID = (int)dr["AlbumHighlightPictureID"]; this.AlbumUserID = (int)dr["AlbumUserID"]; this.AlbumIsPublic = dr.GetBoolean(dr.GetOrdinal("AlbumIsPublic")); } } finally { if(dr!=null)dr.Close(); } However, i get an error at: dr = db.ExecuteReader(cmd); This is its detail: Access is denied Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ComponentModel.Win32Exception: Access is denied Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [Win32Exception (0x80004005): Access is denied] [InvalidOperationException: Cannot open log for source {0}. You may not have write access.] System.Diagnostics.EventLog.OpenForWrite() +363 System.Diagnostics.EventLog.WriteEvent(Int32 eventID, Int16 category, EventLogEntryType type, String[] strings, Byte[] rawData) +280 System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) +462 System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category) +21 System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID) +15 System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type) +11 Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.PerformanceCounterInstances.ReportCounterFailure(String message) Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.PerformanceCounterInstances..ctor(String categoryName, String counterName, Boolean createNewInstance) Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentedEvent.AddPerformanceCounter(String category, String[] counterNames, Boolean createNewInstance) Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentedEvent.Initialize(String counterCategory, String[] counterNames, Boolean createNewInstance, String eventLogSource, EventLogIdentifier[] eventIds) Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentedEvent..ctor(String counterCategory, String[] counterNames, Boolean createNewInstance, String eventLogSource, EventLogIdentifier[] eventIds) Microsoft.Practices.EnterpriseLibrary.Data.Instrumentation.DataServiceEvent..ctor(String[] counterNames, EventLogIdentifier[] eventLogIds) Microsoft.Practices.EnterpriseLibrary.Data.Instrumentation.DataConnectionFailedEvent..ctor(String[] counterNames, EventLogIdentifier[] eventLogIDs) Microsoft.Practices.EnterpriseLibrary.Data.Instrumentation.DataConnectionFailedEvent..cctor() [TypeInitializationException: The type initializer for "Microsoft.Practices.EnterpriseLibrary.Data.Instrumentation.DataConnectionFailedEvent" threw an exception.] Microsoft.Practices.EnterpriseLibrary.Data.Instrumentation.DataConnectionFailedEvent.Fire(String connectionString) +0 Microsoft.Practices.EnterpriseLibrary.Data.Instrumentation.DataInstrumentationFacade.ConnectionFailed(String connectionString) Microsoft.Practices.EnterpriseLibrary.Data.Database.OpenConnection() Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteReader(DBCommandWrapper command) vhGallery.BLL.Album.Load() vhGallery.BLL.Album..ctor(Int32 albumID) vhGallery.AlbumHighlightImage.Page_Load(Object sender, EventArgs e) System.Web.UI.Control.OnLoad(EventArgs e) +67 System.Web.UI.Control.LoadRecursive() +35 System.Web.UI.Page.ProcessRequestMain() +731 ---------------- I try login into sql server with "sa" account and system's Administrator account but that error still occur. What's my problem and how to solve it? Thanks,
    Tuesday, February 1, 2005 8:06 AM

All replies

  • User1763747606 posted
    Check that you have a connection string in your config file similar to: <connectionString name="vhGallery"> <parameters> <parameter name="database" value="mydatabasenamehere" isSensitive="false" /> <parameter name="password" value="mydbpasswordhere" isSensitive="true" /> <parameter name="User ID" value="mydbusernamehere" isSensitive="false" /> <parameter name="server" value="myservernamehere" isSensitive="false" /> </parameters> </connectionString> of course, replace the my... stuff with yours
    Saturday, February 26, 2005 9:22 AM