Enterprise Library 2005 - Data Access Block question.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to add additional database connection information to the
dataConfiguration.config file and have the Data Access Block pick it up?
 
You can add more info there, but you're going to need a way to differentiate
between them. You can edit the code as you see fit, so you can make
whatever changes you want.
 
I have pasted the following code from my dataConfiguration.cofig file.

<?xml version="1.0" encoding="utf-8"?>
<dataConfiguration>
<xmlSerializerSection
type="JDV.EnterpriseLibrary.Data.Configuration.DatabaseSettings,
JDV.EnterpriseLibrary.Data, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null">
<enterpriseLibrary.databaseSettings
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" defaultInstance="Chefs"
xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/data">
<databaseTypes>
<databaseType name="Sql Server"
type="JDV.EnterpriseLibrary.Data.Sql.SqlDatabase, JDV.EnterpriseLibrary.Data,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</databaseTypes>
<instances>
<instance name="Chefs" type="Sql Server" connectionString="Sql
Connection String" />
</instances>
<connectionStrings>
<connectionString name="Sql Connection String">
<parameters>
<parameter name="initial catalog" value="Chefs_Dev"
isSensitive="false" />
<parameter name="Integrated Security" value="true"
isSensitive="false" />
<parameter name="server" value="JDVDEVSQL" isSensitive="false" />
</parameters>
</connectionString>
<connectionString name="Sql Connection String 2">
<parameters>
<parameter name="initial catalog" value="databasename"
isSensitive="false" />
<parameter name="Integrated Security" value="true"
isSensitive="false" />
<parameter name="server" value="SQLServer" isSensitive="false" />
</parameters>
</connectionString>
</connectionStrings>
</enterpriseLibrary.databaseSettings>
</xmlSerializerSection>
</dataConfiguration>

Now, if I make the following changes to the file .... How can I have the
data access block to pick up the second connectionString?

Hope that helps ....


<?xml version="1.0" encoding="utf-8"?>
<dataConfiguration>
<xmlSerializerSection
type="JDV.EnterpriseLibrary.Data.Configuration.DatabaseSettings,
JDV.EnterpriseLibrary.Data, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null">
<enterpriseLibrary.databaseSettings
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" defaultInstance="Chefs"
xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/data">
<databaseTypes>
<databaseType name="Sql Server"
type="JDV.EnterpriseLibrary.Data.Sql.SqlDatabase, JDV.EnterpriseLibrary.Data,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</databaseTypes>
<instances>
<instance name="Chefs" type="Sql Server" connectionString="Sql
Connection String" />
</instances>
<connectionStrings>
<connectionString name="Sql Connection String">
<parameters>
<parameter name="initial catalog" value="Chefs_Dev"
isSensitive="false" />
<parameter name="Integrated Security" value="true"
isSensitive="false" />
<parameter name="server" value="JDVDEVSQL" isSensitive="false" />
</parameters>
</connectionString>
</connectionStrings>
</enterpriseLibrary.databaseSettings>
</xmlSerializerSection>
</dataConfiguration>
 
Do you need access to both string or just one?
Komil said:
I have pasted the following code from my dataConfiguration.cofig file.

<?xml version="1.0" encoding="utf-8"?>
<dataConfiguration>
<xmlSerializerSection
type="JDV.EnterpriseLibrary.Data.Configuration.DatabaseSettings,
JDV.EnterpriseLibrary.Data, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null">
<enterpriseLibrary.databaseSettings
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
defaultInstance="Chefs"
xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/data">
<databaseTypes>
<databaseType name="Sql Server"
type="JDV.EnterpriseLibrary.Data.Sql.SqlDatabase,
JDV.EnterpriseLibrary.Data,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</databaseTypes>
<instances>
<instance name="Chefs" type="Sql Server" connectionString="Sql
Connection String" />
</instances>
<connectionStrings>
<connectionString name="Sql Connection String">
<parameters>
<parameter name="initial catalog" value="Chefs_Dev"
isSensitive="false" />
<parameter name="Integrated Security" value="true"
isSensitive="false" />
<parameter name="server" value="JDVDEVSQL" isSensitive="false"
/>
</parameters>
</connectionString>
<connectionString name="Sql Connection String 2">
<parameters>
<parameter name="initial catalog" value="databasename"
isSensitive="false" />
<parameter name="Integrated Security" value="true"
isSensitive="false" />
<parameter name="server" value="SQLServer" isSensitive="false"
/>
</parameters>
</connectionString>
</connectionStrings>
</enterpriseLibrary.databaseSettings>
</xmlSerializerSection>
</dataConfiguration>

Now, if I make the following changes to the file .... How can I have the
data access block to pick up the second connectionString?

Hope that helps ....


<?xml version="1.0" encoding="utf-8"?>
<dataConfiguration>
<xmlSerializerSection
type="JDV.EnterpriseLibrary.Data.Configuration.DatabaseSettings,
JDV.EnterpriseLibrary.Data, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null">
<enterpriseLibrary.databaseSettings
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
defaultInstance="Chefs"
xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/data">
<databaseTypes>
<databaseType name="Sql Server"
type="JDV.EnterpriseLibrary.Data.Sql.SqlDatabase,
JDV.EnterpriseLibrary.Data,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</databaseTypes>
<instances>
<instance name="Chefs" type="Sql Server" connectionString="Sql
Connection String" />
</instances>
<connectionStrings>
<connectionString name="Sql Connection String">
<parameters>
<parameter name="initial catalog" value="Chefs_Dev"
isSensitive="false" />
<parameter name="Integrated Security" value="true"
isSensitive="false" />
<parameter name="server" value="JDVDEVSQL" isSensitive="false"
/>
</parameters>
</connectionString>
</connectionStrings>
</enterpriseLibrary.databaseSettings>
</xmlSerializerSection>
</dataConfiguration>
 
The application will eventually both strings. When I placed the second
string in the dataConfiguration.config file, the application was not able to
see the second string.
 
Back
Top