DBCommand wrapper not available

Topics: Data Access Application Block, Enterprise Library Core
Mar 2, 2011 at 12:39 PM

Hi,

 I have a dot net 1.1 project, which uses common, configuration and data Enterprises library dlls of version 1.1 (infact we have included these as projects into our dot net project)

Microsoft.Practices.EnterpriseLibrary.Common
Microsoft.Practices.EnterpriseLibrary.Configuration
Microsoft.Practices.EnterpriseLibrary.Data

Now we are trying to migrate the dot net 1.1 application into Dotnet 3.5(VS2008).

1) For this what is the Enterprise library version we have to use?

2)I have EL4.1 and 5.0 with me, and I tried to include these three dll into my migrated dot net project, but I could not find the Microsoft.Practices.EnterpriseLibrary.Configuration dll in my EL bin folder.

3)I tried to include other two dlls, but i got error for common dll, error is:  'Microsoft.Practices.EnterpriseLibrary.Common' , or one of its dependencies, requires a later version of the .NET Framework than the one specified in the project.

4)I tried using data dll only, I am getting DBCommandwrapper is not vailable, through google i came to know that, we have to use  DBCommand, but I am not getting the DBCommand type.

 

Can you please answer the above queries.

Thanks

Sukesh

 

 

Mar 3, 2011 at 2:39 AM

Hi Sukesh,

Please see inline responses :)

1.  EL 4.1 and 5.0 can both work with .NET Framework 3.5 and I would recommend using EL 5.0.

2.  This assembly does not exist in EL 4.1 and 5.0 anymore.

3. This usually happens if you're .NET Framework version is lower than what is required by the assembly being reference (i.e. Microsoft.Practices.EnterpriseLibrary.Common referenced to .NET Framework 2.0 or lower project).

4. DBCommandwrapper does not exist in 4.1 and 5.0 anymore.

Hope this answers all your inquiries. In case you may want to be more specific kindly provide related codes or more description on the current problem you're facing. HTH

Gino Terrado
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Mar 3, 2011 at 3:37 AM

Minor nitpick: Entlib 4.1 and 5.0 target .NET 3.5 SP1, not straight .NET 3.5.

Also, there were major, major changes in the Entlib API from version 1.1 to 2.0. Versions after 2.0 have stayed the same, but the original poster is going to need to do some rewrites.

Mar 3, 2011 at 6:16 AM

Thanks Gino for your quick response

Mar 3, 2011 at 12:14 PM

Hi Gino,

I was able to proceed further with above changes.

But now i am getting different error:


Activation error occured while trying to get instance of type Database, key "MY_CONNECTION"

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

My Web config is like below:

.....

<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="false" />

.......
 <dataConfiguration defaultDatabase="MY_CONNECTION" />  
  <connectionStrings>
    <add name="MY_CONNECTION" connectionString="Driver={SYBASE ASE ODBC Driver};NA=xxxx,1234;srvr=SERVER_1;UID=UID;PWD=PWD;Database=DB1;" />
  </connectionStrings>

........

 

Can you please help me to solve this issue.

 

Thanks,

Sukesh

Mar 4, 2011 at 12:04 AM
Edited Mar 4, 2011 at 12:48 AM

You should set the providerName attribute in your MY_CONNECTION connection string or if you're using the entlib config tool, it's the Database Provider property.

It seems you want to use a Sybase provider.  Note that DAAB doesn't have a built-in provider for Sybase so you need to have your own Sybase provider and do the following:

1. Add an entry in the <providerMappings> for your Sybase database.  You can do this using the entlib configuration tool specifically by adding an entry in the Custom Databases section.

2. Register the Sybase provider either in the machine.config or in your configuration file by adding an entry in the DbProviderFactories element.  Refer here for a sample entry.

If you don't do #2, DAAB will create a GenericDatabase instead of your custom Sybase database class implementation.

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Oct 3, 2011 at 9:25 PM

So how did u solve the configuration reference. Iam trying to do the very same, migrate from entlib 1.0 to 5. Please post back

thanks

Smita

Oct 4, 2011 at 9:40 AM

Hi Smita,

What particular issue did you encountered while migrating from Entlib 1.0 to 5.0? Any exceptions or errors?

 

Noel Angelo Bolasoc
Avanade Software and Cloud Services
Avanade, Inc.
Contact 

Oct 4, 2011 at 10:30 PM

Hi Noel,

This below code gives me error, as it is using this reference

using Microsoft.Practices.EnterpriseLibrary.Configuration;  -- which is no longer there in entlib 5.0

I need to replace the below 2 lines , to retrieve the database name from the config file. 

DatabaseSettings ds = (DatabaseSettings) ConfigurationManager.GetConfiguration("dataConfiguration"); 
DB_NAME = (String)ds.ConnectionStrings[0].Parameters["database"].Value;

 

 

 

 

 

   

Thanks,

Smita

 

 

 

Oct 5, 2011 at 3:38 AM

Replace the ConfigurationManager.GetConfiguration with ConfigurationManager.GetSection and see if this works?

 

Noel Angelo Bolasoc
Avanade Software and Cloud Services
Avanade, Inc.
Contact 

Oct 6, 2011 at 5:54 PM
Hi Noel,
I get this error when i change the code to GetSection
DatabaseSettings ds = (DatabaseSettings)ConfigurationManager.GetSection("dataConfiguration");

Error:
Error 23 The type 'System.Configuration.ConfigurationSection' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. C:\NewBAM\Common\Common\Configuration.cs 32 13 Common


It seems to ask me to reference assembly version 2.0 (is this Entlib 2.0), i want to upgrade to 5.0
thanks
Smita




From: [email removed]
To: [email removed]
Date: Tue, 4 Oct 2011 20:38:19 -0700
Subject: Re: DBCommand wrapper not available [entlib:248134]

From: AvanadeSupport
Replace the ConfigurationManager.GetConfiguration with ConfigurationManager.GetSection and see if this works?

Noel Angelo Bolasoc
Avanade Software and Cloud Services
Avanade, Inc.
Contact
Read the full discussion online.
To add a post to this discussion, reply to this email (entlib@discussions.codeplex.com)
To start a new discussion for this project, email entlib@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com
Oct 7, 2011 at 12:45 AM

Hi,

You also need to add a reference to the System.Configuration. The version 2.0 is the version of the System.Configuration.

 

Noel Angelo Bolasoc
Avanade Software and Cloud Services
Avanade, Inc.
Contact 

Oct 7, 2011 at 6:50 PM
Hi Noel,
Many thanks,
the statement works when i reference System.configuration version 4.0 which i have on my local.
Need one more favour.. how would i replace this statement

DB_NAME = (String)ds.ConnectionStrings[0].Parameters["database"].Value;

thanks,
Smita



From: [email removed]
To: [email removed]
Date: Thu, 6 Oct 2011 17:45:19 -0700
Subject: Re: DBCommand wrapper not available [entlib:248134]

From: AvanadeSupport
Hi,
You also need to add a reference to the System.Configuration. The version 2.0 is the version of the System.Configuration.

Noel Angelo Bolasoc
Avanade Software and Cloud Services
Avanade, Inc.
Contact
Read the full discussion online.
To add a post to this discussion, reply to this email (entlib@discussions.codeplex.com)
To start a new discussion for this project, email entlib@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com
Oct 9, 2011 at 6:45 PM

Hi Smita,

In that case, you need to loop into the ConnectionStringSettingCollection instead. Here is a sample code:

ConnectionStringSettingsCollection connectionStrings =
ConfigurationManager.ConnectionStrings; foreach (ConnectionStringSettings connection in connectionStrings) { string connectionStringName = connection.Name; string connectionString = connection.ConnectionString; string providerName = connection.ProviderName; }

Hope this helps :)

 

Noel Angelo Bolasoc
Avanade Software and Cloud Services
Avanade, Inc.
Contact 

Oct 27, 2011 at 11:37 PM
I dont seem to get this, i could loop through connection strings, but how do i get the database name, and server name. Here is my config file example and below that is the way i did it using entlib 1.0



<?xml version="1.0" encoding="utf-8" ?>
<
configuration>
<
configSections>
<
section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5b2b86dc1561d89b" />
</
configSections>
<dataConfiguration>
<
dataConfiguration defaultDatabase="defaultConnection" />

<
connectionString name="connectionstring">
<
parameters>
<
parameter name="database" value="test" isSensitive="false" />
<
parameter name="pwd" value="4getmenot!" isSensitive="true" />
<
parameter name="server" value="testserver" isSensitive="false" />
<
parameter name="uid" value="appuser" isSensitive="false" />
</
parameters>
</
connectionString>

</
dataConfiguration>
</
configuration>



DB_NAME = (String)ds.ConnectionStrings[0].Parameters["database"].Value;
namedDB = EnterpriseLibraryContainer.Current.GetAllInstances<Database>(DB_NAME);
SERVER_NAME = (String)ds.ConnectionStrings[0].Parameters["server"].Value;



From: [email removed]
To: [email removed]
Date: Sun, 9 Oct 2011 11:45:29 -0700
Subject: Re: DBCommand wrapper not available [entlib:248134]

From: AvanadeSupport
Hi Smita,
In that case, you need to loop into the ConnectionStringSettingCollection instead. Here is a sample code:
ConnectionStringSettingsCollection connectionStrings =
ConfigurationManager.ConnectionStrings; foreach (ConnectionStringSettings connection in connectionStrings) { string connectionStringName = connection.Name; string connectionString = connection.ConnectionString; string providerName = connection.ProviderName; }
Hope this helps :)

Noel Angelo Bolasoc
Avanade Software and Cloud Services
Avanade, Inc.
Contact
Read the full discussion online.
To add a post to this discussion, reply to this email (entlib@discussions.codeplex.com)
To start a new discussion for this project, email entlib@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com
Oct 28, 2011 at 1:17 AM

The connectionstrings section looks like the following:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <connectionStrings>
    <add name="MyConnectionString" connectionString="Database=Database;Server=(local)\SQLEXPRESS;Integrated Security=SSPI"
        providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>

Here's a small program to extract the database and server:

using System;
using System.Configuration;
using System.Data.Common;

namespace ConnectionStrings
{
    class Program
    {
        static void Main(string[] args)
        {
            ConnectionStringSettingsCollection connectionStrings =
                    ConfigurationManager.ConnectionStrings;

            foreach (ConnectionStringSettings connection in connectionStrings)
            {
                string connectionStringName = connection.Name;
                string connectionString = connection.ConnectionString;
                string providerName = connection.ProviderName;

                DbConnectionStringBuilder builder = new DbConnectionStringBuilder();
                builder.ConnectionString = connectionString;

                if (builder.ContainsKey("Database"))
                {
                    Console.WriteLine(builder["Database"]);
                }

                if (builder.ContainsKey("Server"))
                {
                    Console.WriteLine(builder["Server"]);
                }
            }
        }
    }
}

I hope that helps.

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com