multiple connections using enterprise library 2.0

Apr 20, 2007 at 6:05 PM
Hello,

I am using Enterprise library 2.0. I am trying to create multiple connection string in my web.config file.

My web.config file looks like this

<configuration>
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" />
</configSections>
<connectionStrings>
<add name="Connection String" connectionString="server=abcdef;database=team;PWD=pass;UID=sa;"
providerName="System.Data.SqlClient" />
<add name="Connection String1" connectionString="server=abcdef1;database=team1;PWD=pass;UID=sa;"
providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings />

I am accessing this in my program through this code

protected void Page_Load(object sender, EventArgs e)
{
{
Database db = DatabaseFactory.CreateDatabase(ConfigurationManager.AppSettings"Connection String");
string sqlCommand = "sp_getUserId";
DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

// Retrieve products from the specified category.
db.AddInParameter(dbCommand, "NTLogOn", DbType.Int32, "test");

// DataSet that will hold the returned results
DataSet productsDataSet = null;

productsDataSet = db.ExecuteDataSet(dbCommand);
//return productsDataSet;


}
}

On the first line, I get an error The value can not be null or string or empty.\r\nParameter name: id. I am getting this error on
Database db = DatabaseFactory.CreateDatabase(ConfigurationManager.AppSettings"Connection String"); this line.

Any help will be appreciated.

Thanks.
Apr 20, 2007 at 9:35 PM
Hi vinki,

You're probably looking for the Enterprise Libary forum. This is the CodePlex site discussion forum.

Find it here: http://www.codeplex.com/entlib.