The requested database XXX is not defined in the configuration

Topics: Data Access Application Block
Jan 11, 2010 at 4:16 AM

Hello,

I am having a web app in which i have defined the following connection string:

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

<

</font></font><font size="2" color="#0000ff">

 

</font>

 

<font size="2" color="#0000ff">

 

</font>

 

connectionStrings><add name="Dev" connectionString="Data Source=Server; Initial Catalog=db; User ID=User; Password=pwd;" providerName="System.Data.SqlClient" />connectionStrings><dataConfiguration defaultDatabase="Dev"/>

I use a datahelper class having enterprise lib code as follows:

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

public

</font></font><font size="2" color="#0000ff">

 

</font>

 

<font size="2" color="#0000ff">

 

</font>

 

DataSet PopulateDataSet(string connString, string storedProcName)// DataSet that will hold the returned results.

{<font size="2">

 

</font>

 

DataSet productDataSet = null;

try

{

<font size="2">

 

</font>

 

Database db = DatabaseFactory.CreateDatabase(connString);<font size="2">

 

</font>

 

string sqlCommand = storedProcName;DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

productDataSet = db.ExecuteDataSet(dbCommand);

}

 

 catch(Exception ex)

 

{

 

 throw ex;

 

}

 

<font size="2">

 

</font>

 

return productDataSet;

 

}

 

please let me know where i am going wrong.

Jan 11, 2010 at 4:33 AM

What is the value of the connString variable?  Make sure that it corresponds to a connection string name you defined in your config.

 

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com

Jan 11, 2010 at 6:30 AM

Hi Sarah,

The name coincides with that mentioned in the config file. do u want me to mail you the code.

Jan 11, 2010 at 6:34 AM

Sure.

 

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com

Jan 11, 2010 at 7:34 AM

By the way, is that connection string defined in the host project's config file? I mean, if your host project is a web app, it should be in the web config.  If it's a console or a windows app, it should be in the app.config of the console or windows app.

 

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com