G
Guest
I am loading a weeks worth of web logs into a dataset using Imports Microsoft.Data.Odbc
These are text - fixed length fields so I have written a schema for them. The adapter fill looks like this
Dim dt As New DataTable()
Dim cnString As String
Dim adapter As New OdbcDataAdapter()
Dim qs1 As String = "Select * from dl" 'first part of query
....
....
....
While ReadDate < DTEnd 'make query and fill adapter for each selected period
query = Format(ReadDate, "yyyyMMdd") + "#txt" 'construct query
nqs1 = Replace(qs1, "*", "'" + DepName + "' as TName,*") 'add department name to record
query = nqs1 + query 'add first part to query
Try
adapter.SelectCommand = New OdbcCommand(query, conn)
adapter.Fill(ds, TableName) 'get records from logs
Catch ex As Exception
EMsg += query + vbCrLf + cnString + vbCrLf + ex.ToString + vbCrLf + vbCrLf
MsgBox(EMsg)
End Try
ReadDate = DateAdd(DateInterval.Day, 1, ReadDate) 'inc process date
frmMon.Label6.Text = ds.Tables(TableName).Rows.Count.ToString
frmMon.Label6.Refresh()
End While
I then set the table to a view and then bind to a datagrid
dv = ds.Tables(0).DefaultView
frmDG.DataGrid1.DataSource = dv
This all works very well --- until I call this sub again
If I change the date values and run this process again, the app hangs trying to execute the adapter.fill
I modified the app so that a new table "TableName" is sent each time I run the process and this works well ---- but
The memory utilization just keeps increasing until I stop the app. (approx 20Mb per pass.
So I have tried some of the following
ds.Tables.Remove(tn)
ds.Tables(tn).Dispose()
Me.ds.Tables(0).Rows.Clear()
Me.ds.Clear()
Me.dt.Rows.Clear()
Me.dt.Clear()
I found that if I donnot attach the dv to a datagid then I could reload the dataset without changing the name of the datatable
Anyone have ideas on how to release the memory being used to hold the data from the last adapter.fill?
These are text - fixed length fields so I have written a schema for them. The adapter fill looks like this
Dim dt As New DataTable()
Dim cnString As String
Dim adapter As New OdbcDataAdapter()
Dim qs1 As String = "Select * from dl" 'first part of query
....
....
....
While ReadDate < DTEnd 'make query and fill adapter for each selected period
query = Format(ReadDate, "yyyyMMdd") + "#txt" 'construct query
nqs1 = Replace(qs1, "*", "'" + DepName + "' as TName,*") 'add department name to record
query = nqs1 + query 'add first part to query
Try
adapter.SelectCommand = New OdbcCommand(query, conn)
adapter.Fill(ds, TableName) 'get records from logs
Catch ex As Exception
EMsg += query + vbCrLf + cnString + vbCrLf + ex.ToString + vbCrLf + vbCrLf
MsgBox(EMsg)
End Try
ReadDate = DateAdd(DateInterval.Day, 1, ReadDate) 'inc process date
frmMon.Label6.Text = ds.Tables(TableName).Rows.Count.ToString
frmMon.Label6.Refresh()
End While
I then set the table to a view and then bind to a datagrid
dv = ds.Tables(0).DefaultView
frmDG.DataGrid1.DataSource = dv
This all works very well --- until I call this sub again
If I change the date values and run this process again, the app hangs trying to execute the adapter.fill
I modified the app so that a new table "TableName" is sent each time I run the process and this works well ---- but
The memory utilization just keeps increasing until I stop the app. (approx 20Mb per pass.
So I have tried some of the following
ds.Tables.Remove(tn)
ds.Tables(tn).Dispose()
Me.ds.Tables(0).Rows.Clear()
Me.ds.Clear()
Me.dt.Rows.Clear()
Me.dt.Clear()
I found that if I donnot attach the dv to a datagid then I could reload the dataset without changing the name of the datatable
Anyone have ideas on how to release the memory being used to hold the data from the last adapter.fill?