Paul Clapham wrote:Welcome to the Ranch, Jack!
First of all that code won't compile because you declare MainConnection twice, on two consecutive lines. But assuming your real code doesn't have that duplication, it doesn't make sense to me to create a new array each time through the loop. That just throws away the data which earlier iterations through the loop put into the array. You should declare both arrays outside the loop, and you should fill in the remote IP addresses outside the loop as well.
It doesn't do any harm to repeatedly set up the remote IP addresses, but it's kind of confusing and it's better to do things only once. However it does do harm to repeatedly create the MainConnection array.
Jack Tauson wrote:Do you see something wrong with the way I am pulling the records and trying to compare? Please let me know.
Paul Clapham wrote:
Jack Tauson wrote:Do you see something wrong with the way I am pulling the records and trying to compare? Please let me know.
No, I don't see anything wrong with those two things. I already pointed out the problem I did see, so why not work on that one?
Paul Clapham wrote:Well, no, the code you posted will look at all rows of that table every time through the loop. When it does that it's bound to find a row for which ipStatus is 1, since some of the rows are like that, and therefore it will open a new connection and assign it to that array entry for every one of the remote IP addresses.
I'm kind of baffled about what you're trying to do there. What's the point of having a table with 1's and 0's in it when it doesn't tell you which IP address the 1's and 0's belong to?
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |