Connection Pooling

  • Thread starter Thread starter Marco Roberto
  • Start date Start date
M

Marco Roberto

Hi,

does anyone know how to use the connection pooling correctly?
This is my scenario:

I have a simple form with a combobox. I populate this combo with
a dataset every time that the form loads. When I open the form and
I check in my Sql Server I have two connections. If I open another
form I have 4, and so on.
Is there any configuration I have to do in the Sql Server?
My connection string is the same ( I am open the same form serveral
times)
 
Marco,
There is no setup necesary, to use connection pooling effectively make sure
that you open the connection as late as possible and close the connection as
soon as possible. Make sure that the connection is closed by using a
try{..}finally{con.Close} construct or with the c# "using" statement.

For dataset specific scenarios the way to make sure of this is to pass the
connection to the adapter with ConnectionState Closed. When the adapter goes
to fill the dataset and realizes the connection is closed it will open it,
fill the dataset, and close the connection for you.
Hope this helped,
 
Back
Top