Using a run-time defined connection string with Enterprise Library's Data Access Block.

As you can probably tell from previous posts, I'm feel pretty mixed about on the Microsoft Patterns & Practices Enterprise Library Data Access Block (MPAPELDAB, for short).  I like the design of the classes and I really like that you can access databases other than just SQL Server but I'm having some serious problems with registry and event log access exceptions. 

A few days ago, I was trying to access a database using a connection string that I define at run-time.  I double dog dare ya to try to figure that one out.  Wow.  It is not obvious.  Far far extra far from obvious.  The MPAPELDAB appears to be written with the assumptions that...

  1. you will always know your database connection strings at deploy time
  2. they will be in your MPAPELDAB database configuration file

Not bad as assumptions go.  I can see how they would make them cuz probably 99% of the time that's the way it'll roll. 

I found the solution on “Yang's .NET Zone”.  It's non-trivial.  I took the source code, tweeked it a little, and posted my version here.  (NOTE: yes, I know you shouldn't put more than one class or enum per file...I did it so that I only had to post one file instead of 3.)

-Ben

posted @ Thursday, May 05, 2005 11:57 PM

Print

Comments on this entry:

# re: Using a run-time defined connection string with Enterprise Library's Data Access Block.

Left by Kim at 5/6/2005 7:30 AM
Gravatar
Benny, were you getting a little tired last night when you wrote this one? "I'm feel pretty about on the Microsoft Patterns..."
:)
Kimmah

# re: Using a run-time defined connection string with Enterprise Library's Data Access Block.

Left by Harry at 7/12/2005 1:48 PM
Gravatar
Thank you for your post. I use your code (with some modifications such as taking out the public key information, ... etc) and it worked fine.

Thank you again for the great help.

Your comment:



 (will not be displayed)


 
 
 
Please add 5 and 6 and type the answer here:
 

Live Comment Preview:

 
«September»
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789