I have an application that constantly (every 10 seconds) consult info from my DB and store that info in a datatable for the data manipulation, the way I do this is like this:
Public Function BringData(ByVal _Cmd As SqlCommand) As DataTable
Dim _DtbTabla As New DataTable
Try
With _Cmd
.CommandType = CommandType.StoredProcedure
.Connection = Me.Cnn
.CommandTimeout = 0
End With
If Me.Cnn.State = ConnectionState.Closed Then Me.Cnn.Open()
Dim _Adapter As New SqlClient.SqlDataAdapter(_Cmd)
_Adapter.Fill(_DtbTabla)
Catch ex As SqlException
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)
End Try
Return _DtbTabla
End Function
But after 30 to 40 minutes the app starts to freeze for a few seconds if the app runs more time the freezing time also increase.
Debugging the app in the part of _Adapter.Fill(_DtbTabla)
is where the app freeze even if the query just bring a couple of registers, is not a lot of data but here is where the app freeze, what i´m doing wrong or what can i do to solve this?
Thanks in advance 😀