Connection isn't released on MyConnection.Close
Posted by: Karel Boek
Date: November 30, 2004 05:43AM

- MySQL 4.1.7
- Windows 2003 Server
- IIS 6.0
- .NET Framework 1.1
- MySQL Connector/Net (ADO.NET driver for MySQL) version 1.0.2

Connection to a MySQL database is made and values are read into a DataReader, a DataGrid or a DataList. After every connection made, I close the connection and dispose it. However, after a while the error message "too many connections" appears. Using MySQL administrator, I find my web application having 100 (the default) connections to the server.

What is happening here? It seems like my code doesn't really close the connection to the MySQL server. Is that a bug or is it my code (most likely)?

Dim QueryString As String = "SELECT * FROM mytable"
Dim dbConnectionString As String = "Database=db;Data Source=localhost;User Id=*;Password=*"

Dim dbConnection As New MySqlConnection(dbConnectionString)
Dim dbCommand As New MySqlCommand(QueryString, dbConnection)
Dim dbDataReader As MySqlDataReader

dbDataReader = dbCommand.ExecuteReader(CommandBehavior.SingleRow)

While dbDataReader.Read
Return dbDataReader.Item(Setting)
End While

dbConnection = Nothing

Does That Make Sense?

Options: ReplyQuote

Written By
Connection isn't released on MyConnection.Close
November 30, 2004 05:43AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.