Hi
I need to sum X number of fields in an entry of a database (actually an ADO connection to *.xls) for several thousand entries. The fields are all grouped together but X is subject to change. My current code is:
CODE
While Not RS.EOF
For j = intCol To intCol2
sum += RS.Fields("F" + CStr(loopj)).Value
Next
SummaryAList.Add(sum)
sum = nothing
RS.MoveNext()
End While
It seems to be taking a really long time to do this. Does anyone have any suggestions that could possibly speed this up?
intCol and intCol2 are two column markers, sum is declared as double (values are in Excel spreadsheet and accurate to 10 DP)
EDIT:
I fixed the problem somewhat (it is about 2-3 times faster now) by putting each line into an array, then performing the loop on the array. It seems as though the recordset is much slower when moving across it rather than down it.
CODE
RSArray = RS.GetRows(1)
For j = intCol To intCol2
sum += RSArray(j, 0)
Next
This post has been edited by scalt: 27 Jan, 2008 - 12:48 PM