F
Farid
Hi All,
I'm currently working on my first major project using ASP.NET using VB.
Everything seemed fine when i was initially testing but now I'm running into
issues with too many connections being created and taking over the pool.
I've gone through the entire application and verified that I'm calling a
Conn.Close and a Conn.Dispose anywhere that I create and use a SQLConnection
object. However, i'm still running out of connections. I'm the only one in
the application at this time so I figured that the 100 connection pool limit
would suffice. I guess I was wrong!
It's almost as if pooling isn't working. I've read all of the stuff about
the connection string being constant (and it is). All of the connections
share the same connection string (listed below). Since I haven't specified
any values, all pooling parameters are using default values (per Microsoft
documentation). Therefore, my connections should be reused when I execute
this page. .
By executing the same page multiple times I see my the number of my
connections increase by a count of 3 for each iteration. My questions are as
follows:
1. Does my connection string matter in its current format - are there any
parameters that i'm missing that will assist in getting the pool to work
efficiently?
2. I'm using the Microsoft Data Access Application block version 2.0 to save
some coding time. I've looked through the code and it seems to be disposing
of the conneciton objects appropriately -- Nothing is really left hanging
there. Has anyone else had a problem with these before?
I've attached a copy of the code which I believe is a problem.-- why would
this code create 3 connections for every call?
Thanks for all of your help.
Farid
'/****** CODE *******/
ConnString = "data source=MyServer;Trusted_Connection=no;Initial
Catalog=MyDB;User ID=MyUser;Password=MyPwd;"
Private Sub PopulateGrid()
Dim conn As New
SqlConnection(ConfigurationSettings.AppSettings("DBConnString").ToString)
Dim sh As SqlHelper
Dim ds As New DataSet
Try
PrimarySQL = DirectCast(Session("PrimarySQL"), String)
conn.Open()
Dim da As New SqlDataAdapter(PrimarySQL, conn)
da.Fill(ds)
conn.Close()
If ds.Tables(0).Rows.Count <= 0 Then
lblNoRecs.Visible = True
RowCount.Visible = False
DataGrid1.Visible = False
Exit Sub
Else
lblNoRecs.Visible = False
End If
SetRowCount(ds.Tables(0).Rows.Count)
DataGrid1.DataSource = ds
DataGrid1.DataBind()
ds = Nothing
sh = Nothing
Finally
conn.Close()
conn.Dispose()
End Try
I'm currently working on my first major project using ASP.NET using VB.
Everything seemed fine when i was initially testing but now I'm running into
issues with too many connections being created and taking over the pool.
I've gone through the entire application and verified that I'm calling a
Conn.Close and a Conn.Dispose anywhere that I create and use a SQLConnection
object. However, i'm still running out of connections. I'm the only one in
the application at this time so I figured that the 100 connection pool limit
would suffice. I guess I was wrong!
It's almost as if pooling isn't working. I've read all of the stuff about
the connection string being constant (and it is). All of the connections
share the same connection string (listed below). Since I haven't specified
any values, all pooling parameters are using default values (per Microsoft
documentation). Therefore, my connections should be reused when I execute
this page. .
By executing the same page multiple times I see my the number of my
connections increase by a count of 3 for each iteration. My questions are as
follows:
1. Does my connection string matter in its current format - are there any
parameters that i'm missing that will assist in getting the pool to work
efficiently?
2. I'm using the Microsoft Data Access Application block version 2.0 to save
some coding time. I've looked through the code and it seems to be disposing
of the conneciton objects appropriately -- Nothing is really left hanging
there. Has anyone else had a problem with these before?
I've attached a copy of the code which I believe is a problem.-- why would
this code create 3 connections for every call?
Thanks for all of your help.
Farid
'/****** CODE *******/
ConnString = "data source=MyServer;Trusted_Connection=no;Initial
Catalog=MyDB;User ID=MyUser;Password=MyPwd;"
Private Sub PopulateGrid()
Dim conn As New
SqlConnection(ConfigurationSettings.AppSettings("DBConnString").ToString)
Dim sh As SqlHelper
Dim ds As New DataSet
Try
PrimarySQL = DirectCast(Session("PrimarySQL"), String)
conn.Open()
Dim da As New SqlDataAdapter(PrimarySQL, conn)
da.Fill(ds)
conn.Close()
If ds.Tables(0).Rows.Count <= 0 Then
lblNoRecs.Visible = True
RowCount.Visible = False
DataGrid1.Visible = False
Exit Sub
Else
lblNoRecs.Visible = False
End If
SetRowCount(ds.Tables(0).Rows.Count)
DataGrid1.DataSource = ds
DataGrid1.DataBind()
ds = Nothing
sh = Nothing
Finally
conn.Close()
conn.Dispose()
End Try