Hello,
I have an aplication that checks in specific time if database file was changed and if the changes were made shows datatable in dgv
All code is given in Timer Tick. Unfortunately on each 1000 ticks I receive error - System.Data.OleDb.OleDbException (0x800045005) system resources exceeded.
I tried to make a code that dispose / close everything to prevent more than 1000 objects connections but still error appears
My sample code (I removed thingst that are not needed)
Code:
Does anyone could help me solve this problem ?
Thanks
I have an aplication that checks in specific time if database file was changed and if the changes were made shows datatable in dgv
All code is given in Timer Tick. Unfortunately on each 1000 ticks I receive error - System.Data.OleDb.OleDbException (0x800045005) system resources exceeded.
I tried to make a code that dispose / close everything to prevent more than 1000 objects connections but still error appears
My sample code (I removed thingst that are not needed)
Code:
VB.NET:
Try
Using Myconn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & mypath & ";" & "Extended Properties=dBASE IV;")
Using Mycmd As New OleDb.OleDbCommand("SELECT * FROM " & Filename, Myconn)
Using Mydt As New DataTable
Using Myadapter As New OleDb.OleDbDataAdapter(Mycmd)
Myadapter.Fill(Mydt) <- on this line I have an error - System.Data.OleDb.OleDbException (0x800045005)
.....
Myadapter.Dispose()
GC.SuppressFinalize(Myadapter)
Myadapter.Dispose()
End Using
Mydt.Clear()
Mydt.Dispose()
Mydt.Clear()
GC.Collect()
GC.SuppressFinalize(Mydt)
Mydt.Dispose()
End Using
Mycmd.Dispose()
Mycmd.Connection = Nothing
GC.SuppressFinalize(Mycmd)
End Using
Mycn.ConnectionString = Nothing
Mycn.Close()
If Not cn Is Nothing Then
CType(Mycn, IDisposable).Dispose()
End If
GC.SuppressFinalize(Mycn)
Mycn.Dispose()
End Using
Catch ex1 As Exception
Timer1.Stop()
MessageBox.Show("Error occurred: " & vbCrLf & ex1.ToString)
Finally
GC.Collect()
End Try
Does anyone could help me solve this problem ?
Thanks