S
Sylvie
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;
}
}
}
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;
}
}
}