C
cloud
Hi all,
I have a datagridview that has 200000 rows and 5 columns. I need to
extract each row with all the column data and collect in string.
My code is as below:
Dim myList As New List(Of Long)
Dim fieldArray as string
Dim resultArray as string = ""
For Each dr1 As DataGridViewRow In Me.DataGridView1.SelectedRows
myList.Add(dr1.Index)
Next
myList.Sort()
For Each nItem As Integer In myList
Dim dr2 As DataGridViewRow = Me.DataGridView1.Rows(nItem)
ReDim dataGridViewArray(0 To dr2.Cells.Count - 1)
For Each s3 As DataGridViewCell In dr2.Cells
dataGridViewArray(s3.ColumnIndex) =
s3.Value.ToString
Next
fieldArray = ""
'Getting all the column fields from the datagridview
For j = 0 To dataGridViewArray.Length - 1
fieldArray = fieldArray + dataGridViewArray(j)
Next
'Add all the content to the resultArray
resultArray = resultArray + fieldArray ---> exception
next
I have to get all the data in a string form or other
It works when i have less amount of data but if i have massive amounts
of data i get Systen.outofmemoryexception
at resultArray statement.
Thank you for any suggestion...
I have a datagridview that has 200000 rows and 5 columns. I need to
extract each row with all the column data and collect in string.
My code is as below:
Dim myList As New List(Of Long)
Dim fieldArray as string
Dim resultArray as string = ""
For Each dr1 As DataGridViewRow In Me.DataGridView1.SelectedRows
myList.Add(dr1.Index)
Next
myList.Sort()
For Each nItem As Integer In myList
Dim dr2 As DataGridViewRow = Me.DataGridView1.Rows(nItem)
ReDim dataGridViewArray(0 To dr2.Cells.Count - 1)
For Each s3 As DataGridViewCell In dr2.Cells
dataGridViewArray(s3.ColumnIndex) =
s3.Value.ToString
Next
fieldArray = ""
'Getting all the column fields from the datagridview
For j = 0 To dataGridViewArray.Length - 1
fieldArray = fieldArray + dataGridViewArray(j)
Next
'Add all the content to the resultArray
resultArray = resultArray + fieldArray ---> exception
next
I have to get all the data in a string form or other
It works when i have less amount of data but if i have massive amounts
of data i get Systen.outofmemoryexception
at resultArray statement.
Thank you for any suggestion...