Database.CreateDatabase blows up. RRS feed

  • Question

  • User-1078914161 posted

    First of all "Object reference not set to an instance of an object." isn't very informational to me when I call:  

    Database db = Database.CreateDatabase();
      All that tells me is that a null object is being accessed inside this wonderful "time saving" library. Now, when I call: 
    Database db = Database.CreateDatabase("MyDB");
     I get: "The requested database MyDB is not defined in configuration." Now, this makes a little more sense. However look at my App.config file: 
    2    <configuration>
    3      <configSections>
    4        <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    5      </configSections>
    6      <dataConfiguration defaultDatabase="MyDB" />
    7      <connectionStrings>
    8        <add name="MyDB" connectionString="Data Source=(local)\SQLEXPRESS;Initial Catalog=MyDB;User ID=sa;Password=mypass"
    9          providerName="System.Data.SqlClient" />
    10     </connectionStrings>
    11   </configuration>
     My default Database IS MyDB. I thought Initial Catalog ment this was my DEFAULT database. I am using EL 3.1 and I am not very happy with this. I could be writing out full code right now and still be father ahead. Someone explain to me what the problem is? I see blogs saying you need dataConfiguration.config or App.config or Web.config. Which is it? This is getting ridiculous.
    Tuesday, August 14, 2007 2:30 PM

All replies

  • User-1078914161 posted

     Fix this. My App.config is in my Data Objects folder and needed to put the information in my Web.config in my actual application. DLLs get moved over to the bin directory when compiling but config files don't? Go figure...

    Wednesday, August 15, 2007 1:15 PM
  • User-1903045347 posted


    I have the same problem. DId you ever find a solution


    (email: B.McDermott@nasa.gov)

    Thursday, October 11, 2007 8:38 PM
  • User-131038510 posted


      I think you  guys had written the connection string in Inner project like Business layer.. just take the connection string details to the external project app.config or web.config.it will start work....i have the same problem and i resolved in this way.

    Thanks & Regards,




    Tuesday, November 11, 2008 7:43 AM