Yeah, what they said. I definitely wouldn't open the connection any sooner than necessary, but I also wouldn't close it any sooner either. I prefer to get all the data collected and ready to go, then open, process all the stuff, and close. If holding all the data in memory at once isn't an option, then opening and closing for each may be a good idea.