Link to home
Start Free TrialLog in
Avatar of 3803
3803

asked on

Reuse the same oledb.connection object for each aspx form (global.asax?)

I've been looking for this forever.

It just doesn't feel right to recreate a connection object with the same properties (e.g. connectionstring) for each aspx form...

Is there a way to make one connection object (preferably in designtime) and reuse that instance without needing to create one for every form?

It would be nice if I could stil use this same connection when I need to enter it as a property in the .NET enviroment (for example, you need to associate a connection object with a oledb command etc...)

Any help is appreciated!
SOLUTION
Avatar of Timbo87
Timbo87

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 3803
3803

ASKER

Thanks all, I'll split points later, but I would like some further info if possible.

I read about connection pooling elswhere too, but I don't understand very well.

Jetforce wrote this:
If you use the same connection string with the same username and password, by default you are using connection pooling and this is the best way to do it. Once you destroy the connection, the object is returned to the pool and I think it is put in the pool for 3 or 5 minutes (cannot remember which one). This gives greater performance and scalability.

Yes, the connection on each page has indeed the same connectionstring etc.
Where do these 3 to 5 minutes serve for? Is the connection destroyed (and kept in the pool) when you do connection.close or when you go to another page?

What I understand is this: The connectionobject is kept in memory (the pool) when the user leaves a page. The connectionobject is being retrieved from the pool when a new page that has a connection with the same properties is opened.

If, for example, it takes more 3 minutes to open this page, or the user leaves the site, the connection will be released from the pool.

Is that correct?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 3803

ASKER

Thx a lot, hope you guys agree about the points