473,387 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to share the connection?


thanks for your reply Kevin, but I don't understand what do you mean t
"NOT to do that", you mean to declare the same connection and sam
class in every web form ? and what is the built-in connection pooling
please describe it more detail , it is better to show me some simpl
examples, thanks

Kevin Spencer wrote:
[b]Hi dollar,

The best way is NOT to do that. Open and close database connection
as
quickly as possible, and let the built-in Connection Pooling handl
the
rest.

--
HTH,

Kevin Spencer
Microsoft MVP
...Net Developer
What You Seek Is What You Get

-
dolla
-----------------------------------------------------------------------
Posted via http://www.codecomments.co
-----------------------------------------------------------------------

Nov 19 '05 #1
2 1061
Hi Dollar,

when you implement your own connection-pooling objects you will have
problems with datareaders still associated with the connection you want to
re-use. In some cases (I don't why) the reader is still attached and active
although you call the Close method of the datareader. So you will have to
check the reader and some PRIVATE members of the connection to detach the
reader (sounds curious but works). But will have the problem that ADO.Net
checks the connection's state every (I guess) 20 seconds. So will have no
benefit :(

The SqlConnection or the underlying object handles pooling by itself. You
can turn that off with your connection-string (pooling=false).

Regards
Patrick
"dollar" wrote:

thanks for your reply Kevin, but I don't understand what do you mean to
"NOT to do that", you mean to declare the same connection and same
class in every web form ? and what is the built-in connection pooling ?
please describe it more detail , it is better to show me some simple
examples, thanks

Kevin Spencer wrote:
[b]Hi dollar,

The best way is NOT to do that. Open and close database connections
as
quickly as possible, and let the built-in Connection Pooling handle
the
rest.

--
HTH,

Kevin Spencer
Microsoft MVP
...Net Developer
What You Seek Is What You Get.


--
dollar
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

Nov 19 '05 #2
Hi dollar,

What I meant was, do not share a Connection. Open and clase your Connections
as quickly as possible. If they share the same Connection String, they will
be pooled and reused, without your having to do anything special, due to the
built-in Connection Pooling in .Net.

Another way to look at it is this: If you come from an ASP background, and
you're used to having to create and reuse a Connection in order to save
resources used when opening new Connections, you don't have to worry about
that any more. .Net has built-in Connection Pooling that, in a sense,
handles this for you. In fact, it is much safer and better to open and clse
each Connection as quickly as possible. When you close the Connection, you
release it to the Connection Pool. It is not destroyed immediately, but
pooled by the .Net platform.

Does that help?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"dollar" <do***********@mail.codecomments.com> wrote in message
news:do***********@mail.codecomments.com...

thanks for your reply Kevin, but I don't understand what do you mean to
"NOT to do that", you mean to declare the same connection and same
class in every web form ? and what is the built-in connection pooling ?
please describe it more detail , it is better to show me some simple
examples, thanks

Kevin Spencer wrote:
[b]Hi dollar,

The best way is NOT to do that. Open and close database connections
as
quickly as possible, and let the built-in Connection Pooling handle
the
rest.

--
HTH,

Kevin Spencer
Microsoft MVP
...Net Developer
What You Seek Is What You Get.


--
dollar
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

Nov 19 '05 #3

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

Similar topics

8
by: Leo R | last post by:
Hi, Is it possible to create a network-drive at the SYSTEM-level? E.g.: map X: to \\server1\share so a windows service can reach X: without having to log on? I want a Windows .NET service to...
7
by: isamusetu | last post by:
anybody knows how to share the dll between the process? I know there is a way to set the #pragma data_seg in the visual studio 6.0 C++, that can make the dll can be shared between the multiple...
1
by: Macca | last post by:
Hi, I have a C# Solution/Application that contain 4 projects. Each of these projects needs at some time to access the same database. I would like to know how to share a single connection...
0
by: dollar | last post by:
I got it, thanks Kevin Spencer wrote: > Hi dollar, > > What I meant was, do not share a Connection. Open and clase you > Connections > as quickly as possible. If they share the same...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.