E
Elroyskimms
I'm using ASP.Net connecting to MSSQL 2000. I understand that open
connections need to be closed (dbconnection.close) before they can be
returned to the connection pool and re-used. I also understand that if
10 connections are made, each using the exact same connection string,
they will all share the same connection pool, grabbing old connections
if they are available or creating new ones in that pool if there is
nothing available.
All of my connections use the exact same connection string. How do I
know this? Because I have a custom class which has a string called
"ConnectionString" and all of my database connections use it. So, in
theory, I should only have one connection pool showing up in Perf Mon
(SQLClient: Current # Connection Pools) but right now I have 37. Can
anyone help me out with that?
Sample code:
Function qryGetInvoiceTerms() As System.Data.IDataReader
Dim dbConnection As System.Data.IDbConnection = New
System.Data.SqlClient.SqlConnection(sys.ConnectionString)
Dim queryString As String = "SELECT [tblInvoicePaymentTerms].*
FROM [tblInvoicePaymentTerms]"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
dbConnection.Open()
Dim dataReader As System.Data.IDataReader =
dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
Return dataReader
End Function
1) sys.connectionstring is the connection string I have stored in a
separate class
2) Most people freak when they see that I am passing around an open
datareader, but I really do close each one as I go. But even if I
missed one, that shouldn't be causing me to have 37 connection pools...
or should it?
connections need to be closed (dbconnection.close) before they can be
returned to the connection pool and re-used. I also understand that if
10 connections are made, each using the exact same connection string,
they will all share the same connection pool, grabbing old connections
if they are available or creating new ones in that pool if there is
nothing available.
All of my connections use the exact same connection string. How do I
know this? Because I have a custom class which has a string called
"ConnectionString" and all of my database connections use it. So, in
theory, I should only have one connection pool showing up in Perf Mon
(SQLClient: Current # Connection Pools) but right now I have 37. Can
anyone help me out with that?
Sample code:
Function qryGetInvoiceTerms() As System.Data.IDataReader
Dim dbConnection As System.Data.IDbConnection = New
System.Data.SqlClient.SqlConnection(sys.ConnectionString)
Dim queryString As String = "SELECT [tblInvoicePaymentTerms].*
FROM [tblInvoicePaymentTerms]"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
dbConnection.Open()
Dim dataReader As System.Data.IDataReader =
dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
Return dataReader
End Function
1) sys.connectionstring is the connection string I have stored in a
separate class
2) Most people freak when they see that I am passing around an open
datareader, but I really do close each one as I go. But even if I
missed one, that shouldn't be causing me to have 37 connection pools...
or should it?