Re: ArrayList and FilterRow
- From: "TigerMan" <nospam@xxxxxxxxxxxx>
- Date: Fri, 22 Sep 2006 11:54:27 +1000
Thanks for the tip Otis
"Otis Mukinfus" <phony@xxxxxxxxxxxxxxxx> wrote in message
news:7s56h2pjeck3bovh7r5qkr6cn6mmm9bqt7@xxxxxxxxxx
On Fri, 22 Sep 2006 07:03:29 +1000, "TigerMan" <nospam@xxxxxxxxxxxx>
wrote:
Hi,Well, first thing I see is that you are performing two operations in the
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
first
example instead of one. Second, of course the second example is faster
than the
first, because you are simply assigning the same value to the same
variable over
and over again.
IMHO the first example should be ( in C# ):
foreach(string s in aryJobs)
{
string strJbox = "JobNum = " + s + "'";
// or string strJbox = string.format("JobNumb = '{0}'", s);
}
The first example you gave will never be as fast as the second in VB or
any
other language.
Good luck with your project,
Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
.
- References:
- ArrayList and FilterRow
- From: TigerMan
- Re: ArrayList and FilterRow
- From: Otis Mukinfus
- ArrayList and FilterRow
- Prev by Date: Iterating an ADODB RecordSet using System.Reflection
- Next by Date: Most efficient way to process this set of records???
- Previous by thread: Re: ArrayList and FilterRow
- Next by thread: Re: ArrayList and FilterRow
- Index(es):
Relevant Pages
|