As already stated you close and reopen then connection and you have no reason to do that. Afetr opening the connection, fetch the data you need, do the operations you want to and then close the connection. There is no limit how many operations are allowed within a single connection.
When working with connections, commands, and so on, remember to:
- use using statements
- open as late as possible
- close as soon as possible (but do all operations in between)
- handle errors
For examples, have a look at
Properly executing database operations[
^]