C
Chris
I am using the following function in a windows service. It is fired off
by a file system watcher component. It works fine, except for I'll copy
in 20 files it has to process at one time. I'll load up MySqlBrowser to
check the data, and it says I'm out of connections. (the database is
remote) The connections don't clear until I stop the service. Any idea
what I'm missing?
Thanks
Chris
Dim myConnection As MySqlConnection
Dim myCommand As MySqlCommand
Try
Dim myConnectionString As String
myConnectionString = ...
myConnection = New MySqlConnection(myConnectionString)
Dim myInsertQuery As String = GenerateQuery()
myConnection.Open()
myCommand = New MySqlCommand(myInsertQuery)
myCommand.Connection = myConnection
myCommand.ExecuteNonQuery()
For Each S As String In Errors
myCommand.CommandText = "Insert into ImportErrors ....
myCommand.ExecuteNonQuery()
Next
Catch ex As Exception
WriteLog(ex.Message)
Finally
If Not myCommand Is Nothing Then
myCommand.Dispose()
End If
If Not myConnection Is Nothing Then
myConnection.Close()
myConnection.Dispose()
End If
End Try
by a file system watcher component. It works fine, except for I'll copy
in 20 files it has to process at one time. I'll load up MySqlBrowser to
check the data, and it says I'm out of connections. (the database is
remote) The connections don't clear until I stop the service. Any idea
what I'm missing?
Thanks
Chris
Dim myConnection As MySqlConnection
Dim myCommand As MySqlCommand
Try
Dim myConnectionString As String
myConnectionString = ...
myConnection = New MySqlConnection(myConnectionString)
Dim myInsertQuery As String = GenerateQuery()
myConnection.Open()
myCommand = New MySqlCommand(myInsertQuery)
myCommand.Connection = myConnection
myCommand.ExecuteNonQuery()
For Each S As String In Errors
myCommand.CommandText = "Insert into ImportErrors ....
myCommand.ExecuteNonQuery()
Next
Catch ex As Exception
WriteLog(ex.Message)
Finally
If Not myCommand Is Nothing Then
myCommand.Dispose()
End If
If Not myConnection Is Nothing Then
myConnection.Close()
myConnection.Dispose()
End If
End Try