我的移动工作站程序需要连接两个数据库,请问我在使用EnterpriseLibrary的时候,如何创建两个的ConnectionString? <configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=e0b364db0ebed33f" />
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="COO.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<dataConfiguration defaultDatabase="COOCONN" />
<connectionStrings>
<add name="COOCONN" connectionString="Database=COOCONN;Server=(local);Uid=sa;Pwd=123456;Connect Timeout=90" providerName="System.Data.SqlClient" />
</connectionStrings>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=e0b364db0ebed33f" />
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="COO.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<dataConfiguration defaultDatabase="COOCONN" />
<connectionStrings>
<add name="COOCONN" connectionString="Database=COOCONN;Server=(local);Uid=sa;Pwd=123456;Connect Timeout=90" providerName="System.Data.SqlClient" />
</connectionStrings>
<connectionStrings>
<!--
<add name="ConnectionString" connectionString="Data Source=localhost\SQLEXPRESS;Initial Catalog=HibDB;Integrated Security=True" providerName="System.Data.SqlClient"/>
<add name="ConnectionString2" connectionString="Data source=localhost\SQLEXPRESS;Initial Catalog=WealthCollection;Integrated Security=True"/>
-->
<add name="ConnectionString" connectionString="Data Source=LA-ECARD-2003T\SQLSERVER2005;Initial Catalog=HibDB;user=sa;pwd=dep2ls;" providerName="System.Data.SqlClient"/>
<add name="ConnectionString2" connectionString="data source=LA-ECARD-2003T\SQLSERVER2005;initial catalog=TWSLogon;User ID=sa;Password=dep2ls;persist security info=False;packet size=4096"/>
<add name="ConnectionString3" connectionString="Data Source=LA-ECARD-2003T\SQLSERVER2005;Initial Catalog=GGS;user ID=sa;pwd=dep2ls;Integrated Security=false" providerName="System.Data.SqlClient"/>
</connectionStrings>
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None); // Get the conectionStrings section.
ConnectionStringsSection csSection =
config.ConnectionStrings;
for (int i = 0; i <
ConfigurationManager.ConnectionStrings.Count; i++)
{
ConnectionStringSettings cs =
csSection.ConnectionStrings[i];
Console.WriteLine(" Connection String: \"{0}\"",
cs.ConnectionString); Console.WriteLine("#{0}", i);
Console.WriteLine(" Name: {0}", cs.Name);
Console.WriteLine(" Provider Name: {0}",
cs.ProviderName);
}
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=e0b364db0ebed33f" />
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="COO.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<dataConfiguration defaultDatabase="COOCONN" />
<connectionStrings>
<add name="COOCONN" connectionString="Database=COOCONN;Server=(local);Uid=sa;Pwd=123456;Connect Timeout=90" providerName="System.Data.SqlClient" />
<add name="COOCONN1" connectionString="Database=COOCONN;Server=(local);Uid=sa;Pwd=123456;Connect Timeout=90" providerName="System.Data.SqlClient" />
<add name="COOCONN2" connectionString="Database=COOCONN;Server=(local);Uid=sa;Pwd=123456;Connect Timeout=90" providerName="System.Data.SqlClient" />
</connectionStrings>