473,513 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Best Approach to MS EntLib DAAB Database Object

Hi,
I am using a code similar to

Database db = DatabaseFactory.CreateDatabase("MyDB")

in every function of my DAL that interacts directly to database. But
recently I have started getting connection pool errors.

I think, it is because of incorrect usage pattern of Database Object of
DAAB. I want to know that what should be the best approach to it. Shall
I declare it as a static object in class and then use it across the DAL
functions ? My concern is that if during an operation DB object is
locked, then other thread pools would not be able to perform any
database activity. My above assumption could be incorrect, but what
should be the best approach(es) for using EntLib from performance pov.
--
"The human mind is a dangerous plaything, boys. When it's used for evil,
watch out! But when it's used for good, then things are much nicer."
— The Tick
Nov 18 '07 #1
3 2999
Abhishek,

The Database instance shouldn't have to be stored statically. What is
most important is that when you call the methods on the Database which
return object instances which implement IDisposable, you dispose of those
immediately.

I doubt it is related to your Database, but rather, what you do with the
connections returned by calls to the Database object.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Abhishek Tripathi" <pl********@gmail.comwrote in message
news:ON**************@TK2MSFTNGP03.phx.gbl...
Hi,
I am using a code similar to

Database db = DatabaseFactory.CreateDatabase("MyDB")

in every function of my DAL that interacts directly to database. But
recently I have started getting connection pool errors.

I think, it is because of incorrect usage pattern of Database Object of
DAAB. I want to know that what should be the best approach to it. Shall I
declare it as a static object in class and then use it across the DAL
functions ? My concern is that if during an operation DB object is locked,
then other thread pools would not be able to perform any database
activity. My above assumption could be incorrect, but what should be the
best approach(es) for using EntLib from performance pov.
--
"The human mind is a dangerous plaything, boys. When it's used for evil,
watch out! But when it's used for good, then things are much nicer."
— The Tick
Nov 18 '07 #2
Yes, I have identified a few things myself like DataReader objects which
are carried upto business layer, which I would be probing for today.
If I am right about your suggestion regarding disposing dataobjects, you
intend to say that I execute Dispose(dataobject), which would attempt to
run GC to clear out the object from heap. Since the application has to
meet heavy load, how good it would be to call GC frequently ?
Also, what should be an ideal thread pool size for the hosted
application and, also for the database connections, if at anytime there
are 2000 clients hooked up on the server performing data tasks every 1
minute. If by any chance other technical details matter, then we are
using Windows Server 2003, and
SQL 2005 as backend.

Nicholas Paldino [.NET/C# MVP] wrote:
Abhishek,

The Database instance shouldn't have to be stored statically. What
is most important is that when you call the methods on the Database
which return object instances which implement IDisposable, you dispose
of those immediately.

I doubt it is related to your Database, but rather, what you do
with the connections returned by calls to the Database object.

Nov 19 '07 #3
Abhishek,

Yes, I have identified a few things myself like DataReader objects which
are carried upto business layer, which I would be probing for today.
If I am right about your suggestion regarding disposing dataobjects, you
intend to say that I execute Dispose(dataobject), which would attempt to
run GC to clear out the object from heap.
Yes, you should call Dispose on anything that implements IDisposable.

However, you should be aware that if the implementation of IDisposable
adheres to the spirit of the contract (as well as the guidelines for how to
implement IDisposable from MS), then it will ^not^ call GC. It just
releases the (usually) critical resources that the object represents. In
this case, it is the connection t the database.
Since the application has to meet heavy load, how good it would be to call
GC frequently ?
No, absolutely not. Generally, calling GC on your own is a bad thing.
Additionally, if your app is meeting heavy load, and that load is consistent
in its usage profile, then the GC is going to get into a good grove and
initiating a collection on your own would mess with that (ASP.NET is a good
example of an app that does this).
Also, what should be an ideal thread pool size for the hosted application
That completely depends on what you are doing in the thread pool. If
you are performing operations of a long-running nature, then you shouldn't
be using the thread pool. However, if the operations are short, then the
thread pool is fine. The thread pool tunes itself, and you should probably
let it do that on its own (unless through profiling you see that this is a
bottleneck and you thnk you can do better with a more specific
implementation).
and, also for the database connections, if at anytime there are 2000
clients hooked up on the server performing data tasks every 1 minute.
Again, this depends on the tasks that you are performing. If you are
running tasks against the DB that are very quick, then you should just get
an open connection, perform the operation, and then close it.

SQL Server should be able to handle that load though.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

If by any chance other technical details matter, then we are
using Windows Server 2003, and
SQL 2005 as backend.

Nicholas Paldino [.NET/C# MVP] wrote:
>Abhishek,

The Database instance shouldn't have to be stored statically. What is
most important is that when you call the methods on the Database which
return object instances which implement IDisposable, you dispose of those
immediately.

I doubt it is related to your Database, but rather, what you do with
the connections returned by calls to the Database object.

Nov 19 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1845
by: Paul | last post by:
Hi. Just trying to find out the best approach as I beleive it might give me problems later on down the road. I have an ASP.NET application which references a shared database class which...
0
5366
by: sedefo | last post by:
I ran into this Microsoft Patterns & Practices Enterprise Library while i was researching how i can write a database independent data access layer. In my company we already use Data Access...
11
9213
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
3
3937
by: veera sekhar kota | last post by:
hi, im seriously looking for right answer .... We are developing windows application in c#. I implemented DAAB(Data Access Application Block) 2.0 in our application. One of the senior asked...
0
809
by: Mythran | last post by:
I'm not sure how the DAAB for .Net 2.0 works, but the v1.1 DAAB throws SqlException's. Why? When a database raises an error, the DAAB should wrap the error with it's own custom dbms-independant...
4
2417
by: Tarun Mistry | last post by:
Hi all, I have posted this in both the c# and asp.net groups as it applies to both (apologies if it breaks some group rules). I am making a web app in asp.net using c#. This is the first fully OO...
1
3536
by: Eduardo Silva | last post by:
Hi every body i new in dot.net and i am tring to update a table with a data set using entlib i found the way to doit one by one but is any way to doit in one command? Code Sample Dim...
5
1641
by: | last post by:
Hi, I'm having difficulty connecting my .NET web app to my SQL2000 database via the DAAB. I'm using VS2003 with .NET 1.1. I'm currently trying names such as Initial Catalog, Data Source, User...
3
3570
by: rockdale | last post by:
Hi, all: My web application using MS EntLib for .net 2.0 (Jan 2006) to access my backend database. It works fine with MS SQL 2k. Now we are migrate from MS SQL to mySQL. Everything looks fine...
0
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7160
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7099
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7525
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5086
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3233
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1594
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.