Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Enterprise Library Data Access Block 2.0

Enterprise Library Data Access Block 2.0

Scheduled Pinned Locked Moved .NET (Core and Framework)
6 Posts 2 Posters 8 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    saltcode
    wrote on last edited by
    #1

    Hi guys, Please help,I am having an issue with data access block connection to the database from my class library project. using the data access block to connect to database works fine in my website project. but i try creating a separate class library project to connect to the database i now receive an error message. "The value can not be null or an empty string." and this is the code: Database motomandb = DatabaseFactory.CreateDatabase(); DbCommand motomandbCommand = motomandb.GetSqlStringCommand(query); using(DbConnection motomanConnection = motomandb.CreateConnection()) { DbTransaction motomanTransaction = motomanConnection.BeginTransaction(); try { rowsaffected = motomandb.ExecuteNonQuery(motomandbCommand, motomanTransaction); motomanTransaction.Commit(); } catch (Exception e) { motomanTransaction.Rollback(); } } thanks in advance

    C 1 Reply Last reply
    0
    • S saltcode

      Hi guys, Please help,I am having an issue with data access block connection to the database from my class library project. using the data access block to connect to database works fine in my website project. but i try creating a separate class library project to connect to the database i now receive an error message. "The value can not be null or an empty string." and this is the code: Database motomandb = DatabaseFactory.CreateDatabase(); DbCommand motomandbCommand = motomandb.GetSqlStringCommand(query); using(DbConnection motomanConnection = motomandb.CreateConnection()) { DbTransaction motomanTransaction = motomanConnection.BeginTransaction(); try { rowsaffected = motomandb.ExecuteNonQuery(motomandbCommand, motomanTransaction); motomanTransaction.Commit(); } catch (Exception e) { motomanTransaction.Rollback(); } } thanks in advance

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      saltcode wrote:

      i now receive an error message. "The value can not be null or an empty string."

      Where? I'm guessing that it is having problems with the cofiguration file, but without knowing where the error occured it may be somewhere else.


      Upcoming events: * Edinburgh: Web Security Conference Day for Windows Developers (12th April) * Glasgow: Introduction to AJAX (2nd May), SQL Server, Mock Objects My website

      S 1 Reply Last reply
      0
      • C Colin Angus Mackay

        saltcode wrote:

        i now receive an error message. "The value can not be null or an empty string."

        Where? I'm guessing that it is having problems with the cofiguration file, but without knowing where the error occured it may be somewhere else.


        Upcoming events: * Edinburgh: Web Security Conference Day for Windows Developers (12th April) * Glasgow: Introduction to AJAX (2nd May), SQL Server, Mock Objects My website

        S Offline
        S Offline
        saltcode
        wrote on last edited by
        #3

        the error occurred here. Database motomandb = DatabaseFactory.CreateDatabase(); i don't think is the configuration file bcos i connected to the database normally from the web project appcode folder.

        C 1 Reply Last reply
        0
        • S saltcode

          the error occurred here. Database motomandb = DatabaseFactory.CreateDatabase(); i don't think is the configuration file bcos i connected to the database normally from the web project appcode folder.

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          saltcode wrote:

          i don't think is the configuration file bcos i connected to the database normally from the web project appcode folder.

          You've just extracted this out into its own class library and you are still running it as a web application? Is that right? Have you tried stepping into the Enterprise Library code and seeing where it's failing in there? Actually, it should tell you in the stack trace for the exception exactly where in the Enterprise Library it failed. Can you copy and paste the stack trace here?


          Upcoming events: * Edinburgh: Web Security Conference Day for Windows Developers (12th April) * Glasgow: Introduction to AJAX (2nd May), SQL Server, Mock Objects My website

          S 1 Reply Last reply
          0
          • C Colin Angus Mackay

            saltcode wrote:

            i don't think is the configuration file bcos i connected to the database normally from the web project appcode folder.

            You've just extracted this out into its own class library and you are still running it as a web application? Is that right? Have you tried stepping into the Enterprise Library code and seeing where it's failing in there? Actually, it should tell you in the stack trace for the exception exactly where in the Enterprise Library it failed. Can you copy and paste the stack trace here?


            Upcoming events: * Edinburgh: Web Security Conference Day for Windows Developers (12th April) * Glasgow: Introduction to AJAX (2nd May), SQL Server, Mock Objects My website

            S Offline
            S Offline
            saltcode
            wrote on last edited by
            #5

            thanks for your time. here is the trace. System.Configuration.ConfigurationErrorsException was unhandled by user code Message="The type Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null from configuration could not be created. (c:\\inetpub\\wwwroot\\motoman\\web.config line 57)" Source="System.Configuration" BareMessage="The type Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null from configuration could not be created." Filename="c:\\inetpub\\wwwroot\\motoman\\web.config" Line=57 StackTrace: at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult) at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission) at System.Configuration.BaseConfigurationRecord.GetSection(String configKey) at System.Web.Configuration.HttpConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String configKey) at System.Configuration.ConfigurationManager.GetSection(String sectionName) at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSourceImplementation.GetSection(String sectionName) at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource.GetSection(String sectionName) at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings.GetExceptionHandlingSettings(IConfigurationSource configurationSource) at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionHandlingConfigurationView.get_ExceptionHandlingSettings() at Microsoft.Practices.Enterprise

            C 1 Reply Last reply
            0
            • S saltcode

              thanks for your time. here is the trace. System.Configuration.ConfigurationErrorsException was unhandled by user code Message="The type Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null from configuration could not be created. (c:\\inetpub\\wwwroot\\motoman\\web.config line 57)" Source="System.Configuration" BareMessage="The type Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null from configuration could not be created." Filename="c:\\inetpub\\wwwroot\\motoman\\web.config" Line=57 StackTrace: at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult) at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission) at System.Configuration.BaseConfigurationRecord.GetSection(String configKey) at System.Web.Configuration.HttpConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String configKey) at System.Configuration.ConfigurationManager.GetSection(String sectionName) at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSourceImplementation.GetSection(String sectionName) at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource.GetSection(String sectionName) at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings.GetExceptionHandlingSettings(IConfigurationSource configurationSource) at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionHandlingConfigurationView.get_ExceptionHandlingSettings() at Microsoft.Practices.Enterprise

              C Offline
              C Offline
              Colin Angus Mackay
              wrote on last edited by
              #6

              Have you included all the relevant DLLs in the references section. Parts of the Enterprise library load dynamically, so Visual Studio is not completely aware of their necessity so it cannot warn you at compile time. You need the DLL that includs this class: Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler The DLL you need is: Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll It can probably be found in the folder: C:\Program Files\Microsoft Enterprise Library January 2006\bin


              Upcoming events: * Edinburgh: Web Security Conference Day for Windows Developers (12th April) * Glasgow: Introduction to AJAX (2nd May), SQL Server, Mock Objects My website

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups