Search code examples
.netdatabase-connectiontableadapter

How do designer-generated table adapters handle connections


How do table adapters make use of connections?

To explain that a bit, do they automatically open and shut connections or if I already have the connection open before calling a tableadapter method, do they use it and leave it open?

Regards


Solution

  • If you look at the designer-generated code, you'll see that if there is a connection, the adapter reuses it, otherwise it creates a new one. When executing a query method, if the connection isn't open, the method opens it. If the method opened it, it closes it when it is done. By default you get a new connection for every table adapter.