Connections not closing
Posted: Mon 12 Apr 2010 16:11
I have a Windows Service that intermittently checks for the existence of data files. When a file is found it updates a database with the data in the file. This application runs continuously. When I recently upgraded to the current version of dotConnect for MySQL my application began to run out of connections and fail. The connections are not closed and are not made available in a pool.
The vb.net code that is executed when I update the database is:
Dim myConnection As New MySqlConnection(connString)
MyTest = 2
Dim myCommand As New MySqlCommand(QueryString, myConnection)
MyTest = 3
myCommand.CommandType = CommandType.Text
MyTest = 4
myConnection.Open()
MyTest = 5
myCommand.ExecuteNonQuery()
myCommand.Dispose()
myConnection.Close()
myConnection.Dispose()
myConnection = Nothing
In spite of closing and disposing of the connection, the connection remains active for days at a time, only closing when I stop and restart my service.
The connection string looks like this:
Server=www.xyz.com; uid=xxx; pwd=yyy; database=zzz; Connection Lifetime=300;
Thanks,
Art
The vb.net code that is executed when I update the database is:
Dim myConnection As New MySqlConnection(connString)
MyTest = 2
Dim myCommand As New MySqlCommand(QueryString, myConnection)
MyTest = 3
myCommand.CommandType = CommandType.Text
MyTest = 4
myConnection.Open()
MyTest = 5
myCommand.ExecuteNonQuery()
myCommand.Dispose()
myConnection.Close()
myConnection.Dispose()
myConnection = Nothing
In spite of closing and disposing of the connection, the connection remains active for days at a time, only closing when I stop and restart my service.
The connection string looks like this:
Server=www.xyz.com; uid=xxx; pwd=yyy; database=zzz; Connection Lifetime=300;
Thanks,
Art