EDN Admin
Well-known member
Hi,
I have a big problem: I have created a sub that print a datagridview on a file csv:
Public Shared Sub SaveGridDataInFile(ByVal _dgInput As DataGridView, ByVal _sFieldsName() As String, ByVal _iStartIndexField As Integer, ByRef _fName As String, Optional ByVal stampaDaButton As Boolean = True)
Dim objWriter As System.IO.StreamWriter = Nothing
Dim i As Integer
Dim j As Integer
Try
objWriter = New System.IO.StreamWriter(_fName, False)
inserisce titolo
For i = 0 To _sFieldsName.GetUpperBound(0)
objWriter.Write(_sFieldsName(i) + ";")
Next
objWriter.WriteLine()
For j = 0 To (_dgInput.Rows.Count - 1)
parte dallindice di colonna "intStartIndexField" della griglia
For i = _iStartIndexField To (_dgInput.Columns.Count - 1)
If Not TypeOf _dgInput.Item(i, j).Value Is DBNull Then
If _dgInput.Item(i, j).ValueType.Name = "Double" Then
objWriter.Write(_dgInput.Item(i, j).Value.ToString.Replace("."c, ","c))
Else
objWriter.Write(_dgInput.Item(i, j).Value.ToString)
End If
Else
objWriter.Write("")
End If
Next
objWriter.WriteLine()
objWriter.Flush()
Next
objWriter.Close()
Catch ex As Exception
Finally
objWriter.Close()
End Try
End Sub
the datagridview have approximately 250000 rows and 45 columns and at start the application deal with 620mb of ram.
After start printing, I have a error message of "out of memory" and from task manager Isee the application that deal with 1300mb of ram.
the question is: how is possible that the output deal with all this memory? where am I wrong?
View the full article
I have a big problem: I have created a sub that print a datagridview on a file csv:
Public Shared Sub SaveGridDataInFile(ByVal _dgInput As DataGridView, ByVal _sFieldsName() As String, ByVal _iStartIndexField As Integer, ByRef _fName As String, Optional ByVal stampaDaButton As Boolean = True)
Dim objWriter As System.IO.StreamWriter = Nothing
Dim i As Integer
Dim j As Integer
Try
objWriter = New System.IO.StreamWriter(_fName, False)
inserisce titolo
For i = 0 To _sFieldsName.GetUpperBound(0)
objWriter.Write(_sFieldsName(i) + ";")
Next
objWriter.WriteLine()
For j = 0 To (_dgInput.Rows.Count - 1)
parte dallindice di colonna "intStartIndexField" della griglia
For i = _iStartIndexField To (_dgInput.Columns.Count - 1)
If Not TypeOf _dgInput.Item(i, j).Value Is DBNull Then
If _dgInput.Item(i, j).ValueType.Name = "Double" Then
objWriter.Write(_dgInput.Item(i, j).Value.ToString.Replace("."c, ","c))
Else
objWriter.Write(_dgInput.Item(i, j).Value.ToString)
End If
Else
objWriter.Write("")
End If
Next
objWriter.WriteLine()
objWriter.Flush()
Next
objWriter.Close()
Catch ex As Exception
Finally
objWriter.Close()
End Try
End Sub
the datagridview have approximately 250000 rows and 45 columns and at start the application deal with 620mb of ram.
After start printing, I have a error message of "out of memory" and from task manager Isee the application that deal with 1300mb of ram.
the question is: how is possible that the output deal with all this memory? where am I wrong?
View the full article