Web Application using System.Data.oledb.OleDbConnection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all, I've created a web application and currently I'm NOT making use of connection pooling

Right now I have a public shared variable in my Global class of type System.Data.oledb.OleDbConnection. I also have a shared member boolean variable that indicates whether connection has been initialized

Then in my New Sub within the Global class I check the boolean variable and if it is false, then I set it to true and initialize the connection

Then all of the vb classes in my web application uses that single connection object

Since this web application will likely have more than one user accessing it simulataneously - should I be making use of connection pooling? If so, how can I do this "properly"? Also, (connection pooling aside) am I using the right approach in intializing the connection in the New sub? The only thing I really like about my approach is that it
1. makes it easy to change which database my application as a whole connects t
2. ensures that all DB requests are sent to a common Database - as opposed to creating a separate connection object for each class that accesses the database

Lastly, the only way I'll attempt to close the connection is if I get an exception when I open it. Is there an appropriate place to close the connection

Thanks
Novice
 
First, I assume you're using OleDb because you're using JET or some other
data source that does not have a managed .NET data provider. If you're using
JET, consider that it's not designed for use on a web site.
That not withstanding, I have not seen a successful implementation of an
ASP.NET application that shares a common connection. That's what connection
pooling is all about. Yes, each instance should open and close connections
as they are used. I wrote an article on connection pooling some time ago
(see www.betav.com/articles.htm)

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Novice said:
Hi all, I've created a web application and currently I'm NOT making use of connection pooling.

Right now I have a public shared variable in my Global class of type
System.Data.oledb.OleDbConnection. I also have a shared member boolean
variable that indicates whether connection has been initialized.
Then in my New Sub within the Global class I check the boolean variable
and if it is false, then I set it to true and initialize the connection.
Then all of the vb classes in my web application uses that single connection object.

Since this web application will likely have more than one user accessing
it simulataneously - should I be making use of connection pooling? If so,
how can I do this "properly"? Also, (connection pooling aside) am I using
the right approach in intializing the connection in the New sub? The only
thing I really like about my approach is that it:
1. makes it easy to change which database my application as a whole connects to
2. ensures that all DB requests are sent to a common Database - as opposed
to creating a separate connection object for each class that accesses the
database.
Lastly, the only way I'll attempt to close the connection is if I get an
exception when I open it. Is there an appropriate place to close the
connection?
 
Oddly enough I was just using ODB because I was hoping to keep the driver generic. But I have since switched it over to SqlClient since the database being used is VERY unlikely to change

I think you are right that I should be making use of connection pooling and I will read over your article to help guide along the path

After just skimming it over it seems pretty extensive in its coverage of connection pooling. I was actually hoping it would be as easy as just changing my access method for the single connection I have to a method that returns a connection from a connection pool object - but it looks as if there is a little more to it than that

Thanks
Novic
 
Back
Top