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
  1. Home
  2. General Programming
  3. C#
  4. Entlib + config problem

Entlib + config problem

Scheduled Pinned Locked Moved C#
databasehelpsysadminxmlquestion
5 Posts 3 Posters 0 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.
  • D Offline
    D Offline
    dragonius
    wrote on last edited by
    #1

    Hello All, I've got a problem with EntLib 4.1 in combination with my config file. I have a class library for data access which has its own app.config file containing the information for the sql connection.

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    <configSections>
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </configSections>
    <dataConfiguration defaultDatabase="CarOmnia" />
    <connectionStrings>
    <add name="CarOmnia" providerName="System.Data.SqlClient" connectionString="server=(local);database=CarOmnia;User Id=xx;Password=xxxx;" />
    </connectionStrings>
    </configuration>

    Code to access the database:

    public static DataSet SelectAll()
    {
    DataSet retValue = new DataSet();

            try
            {
                Database db = DatabaseFactory.CreateDatabase();
                DbCommand cmd = db.GetStoredProcCommand(stpTest);
                retValue = db.ExecuteDataSet(cmd);
            }
            catch (Exception ex)
            {
                throw ex;
            }
    
            return retValue;
        }
    

    With this go the following includes:

    using System.Data;
    using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
    using Microsoft.Practices.EnterpriseLibrary.Data;
    using System.Data.Common;

    What am i doing wrong, i'm getting the following error on the CreateDatabase() line: {"The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Data.Database, null]) failed: The value can not be null or an empty string. (Strategy type ConfiguredObjectStrategy, index 2)"}

    P B 2 Replies Last reply
    0
    • D dragonius

      Hello All, I've got a problem with EntLib 4.1 in combination with my config file. I have a class library for data access which has its own app.config file containing the information for the sql connection.

      <?xml version="1.0" encoding="utf-8"?>
      <configuration>
      <configSections>
      <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </configSections>
      <dataConfiguration defaultDatabase="CarOmnia" />
      <connectionStrings>
      <add name="CarOmnia" providerName="System.Data.SqlClient" connectionString="server=(local);database=CarOmnia;User Id=xx;Password=xxxx;" />
      </connectionStrings>
      </configuration>

      Code to access the database:

      public static DataSet SelectAll()
      {
      DataSet retValue = new DataSet();

              try
              {
                  Database db = DatabaseFactory.CreateDatabase();
                  DbCommand cmd = db.GetStoredProcCommand(stpTest);
                  retValue = db.ExecuteDataSet(cmd);
              }
              catch (Exception ex)
              {
                  throw ex;
              }
      
              return retValue;
          }
      

      With this go the following includes:

      using System.Data;
      using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
      using Microsoft.Practices.EnterpriseLibrary.Data;
      using System.Data.Common;

      What am i doing wrong, i'm getting the following error on the CreateDatabase() line: {"The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Data.Database, null]) failed: The value can not be null or an empty string. (Strategy type ConfiguredObjectStrategy, index 2)"}

      P Offline
      P Offline
      Programm3r
      wrote on last edited by
      #2

      I had the same problem the other day.... Does the config file that is in the project root directory differ from the one in the Debug directory? If I remember correctly, VS overrites the config file every time you compile or change some settings in the file. Kind regards,

      The only programmers that are better C# programmers, are those who look like this -> :bob:

      :)Programm3r My Blog: ^_^

      D 1 Reply Last reply
      0
      • P Programm3r

        I had the same problem the other day.... Does the config file that is in the project root directory differ from the one in the Debug directory? If I remember correctly, VS overrites the config file every time you compile or change some settings in the file. Kind regards,

        The only programmers that are better C# programmers, are those who look like this -> :bob:

        :)Programm3r My Blog: ^_^

        D Offline
        D Offline
        dragonius
        wrote on last edited by
        #3

        Checked that already, unfortunately they are the same :(

        P 1 Reply Last reply
        0
        • D dragonius

          Checked that already, unfortunately they are the same :(

          P Offline
          P Offline
          Programm3r
          wrote on last edited by
          #4

          What about the <app name>.exe.config ? Is that perhaps different? Otherwise run the Enterprise Library Configuration tool and set the values again in all config files....

          The only programmers that are better C# programmers, are those who look like this -> :bob:

          :)Programm3r My Blog: ^_^

          1 Reply Last reply
          0
          • D dragonius

            Hello All, I've got a problem with EntLib 4.1 in combination with my config file. I have a class library for data access which has its own app.config file containing the information for the sql connection.

            <?xml version="1.0" encoding="utf-8"?>
            <configuration>
            <configSections>
            <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
            </configSections>
            <dataConfiguration defaultDatabase="CarOmnia" />
            <connectionStrings>
            <add name="CarOmnia" providerName="System.Data.SqlClient" connectionString="server=(local);database=CarOmnia;User Id=xx;Password=xxxx;" />
            </connectionStrings>
            </configuration>

            Code to access the database:

            public static DataSet SelectAll()
            {
            DataSet retValue = new DataSet();

                    try
                    {
                        Database db = DatabaseFactory.CreateDatabase();
                        DbCommand cmd = db.GetStoredProcCommand(stpTest);
                        retValue = db.ExecuteDataSet(cmd);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
            
                    return retValue;
                }
            

            With this go the following includes:

            using System.Data;
            using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
            using Microsoft.Practices.EnterpriseLibrary.Data;
            using System.Data.Common;

            What am i doing wrong, i'm getting the following error on the CreateDatabase() line: {"The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Data.Database, null]) failed: The value can not be null or an empty string. (Strategy type ConfiguredObjectStrategy, index 2)"}

            B Offline
            B Offline
            bross gwlc com
            wrote on last edited by
            #5

            Make sure you save your application. You will get this if the application is not saved OR if the app.config is missing. -Josh

            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