G
Guest
I have the following code in a web form which use a connection to SQL Server
2000. I use this form to display a list of products from a table. The
connection string to the database server is stored in web.config file.
public partial class VizualizareProduse : System.Web.UI.Page
{
protected SqlConnection con;//conexiunea spre baza de date
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack == false)
{
string ConnectionString =
WebConfigurationManager.ConnectionStrings["companieConnectionString"].ConnectionString;
con = new SqlConnection(ConnectionString);
try
{
con.Open();
}
catch (Exception eExecutie)
{
//capturam erorile ce apar
}
finally
{
con.Close();
con.Dispose();
}
}
}
after this page is load and the line of code con.Close() is parsed the
connection to the databse server still remain open ???Why??? I tried to
eliminate the object from memory with con.Dispose(); The connection still
remain open. (This is very confused to me. Sql Server still see the
connection in Current activity node enen if I click the refresh option from
the dropdown menu)
Can anyone tell me what I am doing wrong?
Thank you very much for your time,
Horia
2000. I use this form to display a list of products from a table. The
connection string to the database server is stored in web.config file.
public partial class VizualizareProduse : System.Web.UI.Page
{
protected SqlConnection con;//conexiunea spre baza de date
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack == false)
{
string ConnectionString =
WebConfigurationManager.ConnectionStrings["companieConnectionString"].ConnectionString;
con = new SqlConnection(ConnectionString);
try
{
con.Open();
}
catch (Exception eExecutie)
{
//capturam erorile ce apar
}
finally
{
con.Close();
con.Dispose();
}
}
}
after this page is load and the line of code con.Close() is parsed the
connection to the databse server still remain open ???Why??? I tried to
eliminate the object from memory with con.Dispose(); The connection still
remain open. (This is very confused to me. Sql Server still see the
connection in Current activity node enen if I click the refresh option from
the dropdown menu)
Can anyone tell me what I am doing wrong?
Thank you very much for your time,
Horia