Click here to Skip to main content
15,893,588 members

Comments by Jαved (Top 143 by date)

Jαved 12-Mar-18 3:32am View    
use below code-

Dim _New_dt As New DataTable()

_New_dt = dt

dt.Columns.Add("Key_Id", GetType(String))

Dim c = _New_dt.Rows.Count / 30000
Dim SheetNumber = Convert.ToInt64(System.Math.Ceiling(c))
' If c = CDbl(c) Then
'c = System.Math.Floor(c + 1)

Dim dtArr(c) As DataTable
For j = 0 To c
dtArr(j) = dt.Select("key_id <= 1 And key_id >= 30000").CopyToDataTable()
dtArr(j) = dt.Select("key_id <= 61000 And key_id >= 90000").CopyToDataTable()
dtArr(j) = dt.Select("key_id <= 91000 And key_id >= 120000").CopyToDataTable()
dtArr(j) = dt.Select("key_id <= 121000 And key_id >= 150000").CopyToDataTable()
Next

'End If
Jαved 12-Mar-18 3:19am View    
Hi Maciej,
thanks for suggestion I only saw updated time.
Jαved 12-Mar-18 3:16am View    
you are looping through all the rows in main table 'dt' un-necessarily and the batchSize check is in middle of the loop it should be the first check in the loop.
Although this code will take lot of time and is not optimized.
Jαved 12-Mar-18 2:55am View    
Yes, declare another variable to set count to split and declare dtArr to be DataTable array as - Dim dtArr() as DataTable and in loop set array as-
dtArr(i) = dt.Select("key_id <= 1 And key_id >= 30000").CopyToDataTable()
Jαved 12-Mar-18 2:35am View    
nope, it is decimal the code will not work and give error.