PC Review


Reply
Thread Tools Rate Thread

Connection Pooling

 
 
Sylvie
Guest
Posts: n/a
 
      8th Oct 2007
I have a static function in a class, everytime I call this function, I am
creating a SQLconnection, open it, use it, and null it, All my functions and
application logic is like this,

Every connection is creating self connection object and null it after the
some process,

Is this wrong ?

One of my friend told me about "Connection Pooling", and I am confused
enough, Only one connection can be used in all part of the applicaton
(whether web or windows application)

//

using System.Data;

using System.Data.SqlClient;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

public class Langs

{

public Langs()

{

}

public static void GetLanguageList()

{

SqlConnection ConnLocal = new
SqlConnection(DataFace.GetSQLConnectionString());

try

{

SqlCommand CommLocal = new SqlCommand();

CommLocal.Connection = ConnLocal;

CommLocal.CommandText += "SELECT bla bla bla";

ConnLocal.Open();

SqlDataReader rdLocal =
CommLocal.ExecuteReader(CommandBehavior.CloseConnection);

if (rdLocal.HasRows)

{

while (rdLocal.Read())

{

}

if (rdLocal.IsClosed != false)

{

rdLocal.Close();

}

}

catch (Exception Exx)

{

throw Exx

}

finally

{

ConnLocal = null;

}

}

}



 
Reply With Quote
 
 
 
 
=?Utf-8?B?SklHTkVTSA==?=
Guest
Posts: n/a
 
      8th Oct 2007
Connection Pooling is automatically taken care by ADO.NET Managed Providers.
This link will give you more insight. Happy Reading..

http://www.ondotnet.com/pub/a/dotnet.../connpool.html

Regards
JIGNESH.


"Sylvie" wrote:

> I have a static function in a class, everytime I call this function, I am
> creating a SQLconnection, open it, use it, and null it, All my functions and
> application logic is like this,
>
> Every connection is creating self connection object and null it after the
> some process,
>
> Is this wrong ?
>
> One of my friend told me about "Connection Pooling", and I am confused
> enough, Only one connection can be used in all part of the applicaton
> (whether web or windows application)
>
> //
>
> using System.Data;
>
> using System.Data.SqlClient;
>
> using System.Configuration;
>
> using System.Web;
>
> using System.Web.Security;
>
> using System.Web.UI;
>
> using System.Web.UI.WebControls;
>
> using System.Web.UI.WebControls.WebParts;
>
> using System.Web.UI.HtmlControls;
>
> public class Langs
>
> {
>
> public Langs()
>
> {
>
> }
>
> public static void GetLanguageList()
>
> {
>
> SqlConnection ConnLocal = new
> SqlConnection(DataFace.GetSQLConnectionString());
>
> try
>
> {
>
> SqlCommand CommLocal = new SqlCommand();
>
> CommLocal.Connection = ConnLocal;
>
> CommLocal.CommandText += "SELECT bla bla bla";
>
> ConnLocal.Open();
>
> SqlDataReader rdLocal =
> CommLocal.ExecuteReader(CommandBehavior.CloseConnection);
>
> if (rdLocal.HasRows)
>
> {
>
> while (rdLocal.Read())
>
> {
>
> }
>
> if (rdLocal.IsClosed != false)
>
> {
>
> rdLocal.Close();
>
> }
>
> }
>
> catch (Exception Exx)
>
> {
>
> throw Exx
>
> }
>
> finally
>
> {
>
> ConnLocal = null;
>
> }
>
> }
>
> }
>
>
>
>

 
Reply With Quote
 
William Vaughn
Guest
Posts: n/a
 
      8th Oct 2007
See www.betav.com/blog/billva and search for "pooling" or "connecting".

hth

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant, Dad, Grandpa
Microsoft MVP
INETA Speaker
www.betav.com
www.betav.com/blog/billva
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

"Sylvie" <(E-Mail Removed)> wrote in message
news:%23xB$(E-Mail Removed)...
>I have a static function in a class, everytime I call this function, I am
> creating a SQLconnection, open it, use it, and null it, All my functions
> and
> application logic is like this,
>
> Every connection is creating self connection object and null it after the
> some process,
>
> Is this wrong ?
>
> One of my friend told me about "Connection Pooling", and I am confused
> enough, Only one connection can be used in all part of the applicaton
> (whether web or windows application)
>
> //
>
> using System.Data;
>
> using System.Data.SqlClient;
>
> using System.Configuration;
>
> using System.Web;
>
> using System.Web.Security;
>
> using System.Web.UI;
>
> using System.Web.UI.WebControls;
>
> using System.Web.UI.WebControls.WebParts;
>
> using System.Web.UI.HtmlControls;
>
> public class Langs
>
> {
>
> public Langs()
>
> {
>
> }
>
> public static void GetLanguageList()
>
> {
>
> SqlConnection ConnLocal = new
> SqlConnection(DataFace.GetSQLConnectionString());
>
> try
>
> {
>
> SqlCommand CommLocal = new SqlCommand();
>
> CommLocal.Connection = ConnLocal;
>
> CommLocal.CommandText += "SELECT bla bla bla";
>
> ConnLocal.Open();
>
> SqlDataReader rdLocal =
> CommLocal.ExecuteReader(CommandBehavior.CloseConnection);
>
> if (rdLocal.HasRows)
>
> {
>
> while (rdLocal.Read())
>
> {
>
> }
>
> if (rdLocal.IsClosed != false)
>
> {
>
> rdLocal.Close();
>
> }
>
> }
>
> catch (Exception Exx)
>
> {
>
> throw Exx
>
> }
>
> finally
>
> {
>
> ConnLocal = null;
>
> }
>
> }
>
> }
>
>
>


 
Reply With Quote
 
JonOfAllTrades
Guest
Posts: n/a
 
      30th Nov 2007
"Sylvie" wrote:

> I have a static function in a class, everytime I call this function, I am
> creating a SQLconnection, open it, use it, and null it, All my functions and
> application logic is like this,
>
> Every connection is creating self connection object and null it after the
> some process,
>
> Is this wrong ?


I can't speak for pooling, but don't you need to either Close() your
SqlConnections, rather than just cutting them off? The server will kill them
automatically, eventually, but you may generate hundreds of connections
first, and that can be a performance hit. Perhaps the GC and Dispose() will
take care of it, but that might not happen right away, either.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I force connection pooling to keep at least one connection alive ? TheSteph Microsoft C# .NET 6 22nd Nov 2007 03:25 PM
Connection pooling parameters not working for Oracle connection yoram.ayalon@structuredweb.com Microsoft ADO .NET 1 29th Sep 2006 09:36 PM
Re: ADO.NET, connection pooling and ASP.NET Rob Nicholson Microsoft ADO .NET 0 31st Aug 2005 06:31 PM
connection in connection pool with pooling=false Jason Collins Microsoft ADO .NET 10 22nd Jun 2004 01:21 PM
How do I turn off connection pooling in a connection string corbett Microsoft Dot NET 1 6th Jan 2004 11:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:18 PM.