My knowledge in the field is limited, so I can not give you a lot of details on this issue, but as far as I know, the process of creating connections and transferring them to the stream is really worth the resources, so I would avoid it if I were you. In any case, I think that most of these solutions cannot be generalized and depend on the business.
If, for example, your application constantly interacts with the database and stops only when the application is closed, then possibly constant connections are the way to go because you avoid the process mentioned above.
However, if your application only occasionally contacts the database in order to get a little information, then closing the connection may be more reasonable, since you will not spend resources on open connections that are not used.
There is also a method called the Connection Pool, in which you create a series of a priori connections and save them there for use by other applications. In this case, the connections are stored in the database, but are not application resistant.
Note. Connections in MSSQL are always persistent for the database, since the connection pool is the default behavior.
Pedroc88
source share