T
TigerMan
Hi,
I have an interesting problem. With the code below, the loop takes ages to
run:
For intA = 0 To aryJobs.Count - 1
Dim strJobx As String = aryJobs(intA).ToString
strJobx = "JobNumb = '" & strJobx & "'"
adsWork.Tables(0).DefaultView.RowFilter = strJobx
......
Next intA
......
If I change it to this, it is super fast:
For intA = 0 To aryJobs.Count - 1
Dim strJobx As String strJobx = "JobNumb = '00001"
adsWork.Tables(0).DefaultView.RowFilter = strJobx
......
Next intA
.......
Yet the first item in the ArrayList(0) is "00001" so why is it way slower
when I try to pass an ArrayList rather than the number 00001 as seen above?
I have also tried an array of string with the same slow result. I have left
the code out where the ... are as the perfomance problem is in the above
code. Is this problem because setting the number direct is like a constant
where getting it from an arraylist is really slow?
The reason I have to do this is because i am upgrading data where there is a
'jobnumb' field in an access table but there could be several records for it
under 1 job number, however the source is flat file and one job could have a
different extension (say one part might be 00001-02A and another part
00001-02 and so on and many variations on that) so I create a datatable that
I add temp fields too so I can get the job number to be the same so I can
filter the records and I built an arraylist of unique jobnumbs then I can
import the records to a new relational setup so there is only 1 jobnumb with
relations to other tables. I tied making a temp table but no difference.
TIA
I have an interesting problem. With the code below, the loop takes ages to
run:
For intA = 0 To aryJobs.Count - 1
Dim strJobx As String = aryJobs(intA).ToString
strJobx = "JobNumb = '" & strJobx & "'"
adsWork.Tables(0).DefaultView.RowFilter = strJobx
......
Next intA
......
If I change it to this, it is super fast:
For intA = 0 To aryJobs.Count - 1
Dim strJobx As String strJobx = "JobNumb = '00001"
adsWork.Tables(0).DefaultView.RowFilter = strJobx
......
Next intA
.......
Yet the first item in the ArrayList(0) is "00001" so why is it way slower
when I try to pass an ArrayList rather than the number 00001 as seen above?
I have also tried an array of string with the same slow result. I have left
the code out where the ... are as the perfomance problem is in the above
code. Is this problem because setting the number direct is like a constant
where getting it from an arraylist is really slow?
The reason I have to do this is because i am upgrading data where there is a
'jobnumb' field in an access table but there could be several records for it
under 1 job number, however the source is flat file and one job could have a
different extension (say one part might be 00001-02A and another part
00001-02 and so on and many variations on that) so I create a datatable that
I add temp fields too so I can get the job number to be the same so I can
filter the records and I built an arraylist of unique jobnumbs then I can
import the records to a new relational setup so there is only 1 jobnumb with
relations to other tables. I tied making a temp table but no difference.
TIA