Using .NET Connector 1.3; When visiting the website, the code picks some strings from a MySql table, i.e. a copyright notice that is displayed in the footer. After that, I call both 'dbConnection.Close' and 'dbConnection.Dispose'
The problem is that either connection is not disposed, or the connection is not released, since for each unique visitor, a new connection appears in the MySql Administrator connection list with status 'Sleep'; this connection remains there until the timeout is elapsed. Since this website has had quite a number of visitors in the past days, I had to extend the 'max connections' and limit the timeout time so that we wouldn't get errors like 'too many connections'
Here's a part of the code:
Function MyFunction
Dim dbConnectionString As String = "Database=commodoreshop;Data Source=***.***.***.***;Port=***;User Id=***;Password=***"
Dim dbConnection As New MySqlConnection(dbConnectionString)
Dim QueryString As String = "SELECT * FROM myTable"
Dim dbDataTable As New DataTable
Dim dbDataAdapter As New MySqlDataAdapter(QueryString, dbConnection)
Try
dbDataAdapter.Fill(dbDataTable)
Catch ex As Exception
'Insert error handling here
End Try
dbConnection.Close()
dbConnection.Dispose()
Return dbConnection.State.ToString
End Function
As you can see, the only thing that this function returns is the connection state; the result of this return is "Closed". Can anyone tell me what to do to really dispose or release the connection?