locked
Activation error occured while trying to get instance of type Database, key "DBName" RRS feed

  • Question

  • User-1964369394 posted

    Im using Enterprise library 5.0
    I have a scenario, where I have to access two different databases in my application.

    Basically this application is a webservice,delployed on my local for testing purpose.
    I'm trying to access this web method from diffent windows application, default connection works fine but the other database throw's exception.

    Problem is only my defaultDatabase is works fine, if I change defaultDatabase="MYCON1" with "MYCON2" it works fine, if I try to access the other database which is not default, throws exception.

    <dataConfiguration defaultDatabase="MYCON1" />
    <connectionStrings>
    <add name="MYCON1" connectionString="Data Source=server1;Initial Catalog=dbName1;User Id=Username1;Password=password1;"
    providerName="System.Data.SqlClient

    " />
    <add name="MYCON2" connectionString="Data Source=Server2;Initial Catalog=dbName2;User Id=Username2;Password=password2;"
    providerName="System.Data.SqlClient" />
    </connectionStrings>


    Database myDB=EnterpriseLibraryContainer.Current.GetInstance<Database>(); --> works fine for the default database (MYCON1)


    Database myDB=EnterpriseLibraryContainer.Current.GetInstance<Database>("MYCON2"); --> Error message, see below


    Activation error occured while trying to get instance of type Database, key "MYCON2"
    Thursday, July 29, 2010 11:59 AM

All replies

  • User-1964369394 posted

    Does this make any sense? Im I doing it correctly?

    Monday, August 2, 2010 1:52 PM
  • User-174320665 posted

    I don't see any issues with the syntax. I have used similer code & it works fine. Does your second database exists? 

    Friday, August 27, 2010 5:36 AM
  • User1473440273 posted

    Any update on this post?


    Thanks

    Sabarish



    Thursday, November 25, 2010 5:28 AM
  • User996616593 posted

    Hi

    We are new to Enterprise Library and .net also, we are getting the same error , May i know how it worked for one database, because we are not able to configure for single database also. Can you please tell how you configured for single database.

     

    Thank u in advance,

    phani

    Monday, February 28, 2011 11:33 PM
  • User-1416663342 posted

    Hi have you find any solution for this? we are also gettng the same issue?

    If you could provide any info is greately appreciated..

    Thanks,

    Srini

    Monday, August 6, 2012 2:53 PM