Click here to Skip to main content
14,877,543 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm receiving the following error:

The type Database cannot be constructed. You must configure the container to supply this value.

Exception Details: System.InvalidOperationException: The type Database cannot be constructed. You must configure the container to supply this value.

C#
Source Error:


Line 168:        public DataSet ExecuteDataSet(string strSpName, List<CommandParameter> objLstParameter = null, List<string> tableNames = null)
Line 169:        {
Line 170:            Database objDatabase = (Database)DatabaseFactory.CreateDatabase();
Line 171:            using (DbConnection objDbConn = objDatabase.CreateConnection())
Line 172:            {


Here are the list of references I have added.

Microsoft.Practices.EnterpriseLibrary.Common.dll, Microsoft.Practices.EnterpriseLibrary.Data.dll
Microsoft.Practices.ServiceLocation.dll
Microsoft.Practices.Unity.dll
Microsoft.Practices.Unity.Interception.dll

Here is the app.config that I've created for the solution:

XML
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
  </configSections>
  <dataConfiguration defaultDatabase="ConnectionString" />
  <connectionStrings>
    <add name="ConnectionString" connectionString="Data Source=xxxxxx; Persist Security Info=True;Initial Catalog = xxxx;user id = xxxxx; password = xxxx"
        providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>


Please let me know where I'm making mistake.
Posted

C#
I resolved this error by doing the step below

From the NuGet Package Manager Console, run the following command:
Install-Package EntLibContrib.Data.OdpNet
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900