我有一些简单的代码可以解析有300,000行的DataGridView
。当i = 190,000时,抛出System.OutOfMemoryException
。是否有可能解析我的所有DataGridView
行,或者我必须找到另一种解决方案吗?
Dim dt As New DataTable()
dt = ReadTextFile()
GridEx2.DataSource = dt
' I can delete all rows that I don't need
'and after that i insert all into my table
For i As Integer = 0 To GridEx2.Rows.Count - 1
If GridEx2.Rows(i).Cells(0).Value & "" & GridEx2.Rows(i).Cells(1).Value & "" <> "" Then
Dim dictionary As New Dictionary(Of String, String)
'here i have an another grid where I select table column name = grid column name
'one row contains 2 column table column name and grid column name
For j As Integer = 0 To GridEx1.Rows.Count - 1
Dim tabCol As String = GridEx1.Rows(j).Cells(tableColumnName)
Dim gridCol As String = GridEx1.Rows(j).Cells(gridColumName)
dictionary(tabCol) = GridEx2.Rows(i).Cells(gridCol).Value
Next
'here I parse my dictionary and insert into DB
End If
Next