Microsoft.Practices.EnterpriseLibrary.Data.Database.GetDataAdapter(Microsoft.Practices.EnterpriseLibrary.Data.UpdateBehavior)' is inaccessible due to its protection level

Topics: Data Access Application Block, General discussion
Jul 25, 2011 at 4:43 PM

The following code is valid, compiles and works using .net 1.1 and EL 4.1:

DbDataAdapter da = OutsideBusinessDatabaseFactory.CreateDatabase(dbInstanceName).GetDataAdapter(UpdateBehavior.Transactional);
However, in EL 5.0 the code no longer compiles because of a protection error.  Looking in the EL using object browser, GetDataAdapter() now returns an IDbDataAdapter, and GetDataAdapter(UpdateBehavior) still returns a DbDataAdapter, but is now declared as protected.
Obviously, Microsoft intends for the developer to do something differently, but what?  There is no clue, and no online discussions anywhere that I've looked describes this issue.
Any help would be much appreciated.
Jul 25, 2011 at 7:05 PM



Jul 25, 2011 at 10:08 PM

Entlib 4.1 does not work on .NET 1.1. Could you double check the version numbers and clarify what platform you're on?


Jul 25, 2011 at 10:44 PM

Previously using EL 4.1 on .net 1.1, attempting to migrate to EL 5.0 using .net 3.5.  Thanks.



Jul 26, 2011 at 7:00 AM

I'm not sure what is going on here exactly but as Chris just said,  Enterprise Library 4.1 will not work with .NET Framework 1.1. It is stated on Enterprise Library 4.1 System Requirements, the minimum framework required is 3.5. 


Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
Contact Us

Jul 26, 2011 at 2:56 PM

Well, I know what we have here, but that doesn't matter.  Call it version X.  This code compiled and ran in version X with no problem, in version 5.0 it doesn't compile.

Obviously, Microsoft is trying to make the programmer do something different by changing the method to make it protected.  What does Microsoft want the programmer to do?  This application has 30 calls of this type, and there are a dozen more applications with the same issue.

Jul 26, 2011 at 3:46 PM

To phrase the question differently, given an EL 5.0 database object, what is the correct way to get a transactional data adapter?  Thanks.

Jul 26, 2011 at 9:31 PM



Jul 27, 2011 at 5:36 AM
Edited Jul 27, 2011 at 11:05 AM

Though I haven't tested this yet, I think you can leverage the TransactionScope. Here is my sample code:


Database db = EnterpriseLibraryContainer.Current.GetInstance<Database>();

//use DatabaseFactory.CreateDatabase for version prior to 5.0
//Database db = DatabaseFactory.CreateDatabase();

DbDataAdapter da = db.GetDataAdapter();
using (TransactionScope transactionScope = new TransactionScope())
      //DataAdapter operations...


Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
Contact Us

Jul 27, 2011 at 2:41 PM

Thanks for this.  I don't find a TransactionScope class in my project, maybe I'm missing the piece of EL where it lives?  Also, the code returns a transaction-capable dataadapter to its caller, and it gets processed elsewhere; is there no way to attach the transactional capability to the adapter as previously?

Jul 27, 2011 at 9:30 PM


Jul 28, 2011 at 10:29 AM

The code I posted is the work around I can think of to make the DataAdapter transactional.  I can't find any means to make the data adapter transaction-capable since like you already said, the previous overload method is already protected. I don't have an idea why Microsoft make it that way (its not documented elsewhere). I believe you really need to modify your code to adapt to this changes.


Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
Contact Us