.netasp.netdatabase-connectivity

Question regarding SQL connection in a web application


I have a doubt regarding the sql database connection that we open for performing CRUD statements on the database in the context of web application (a web store) in asp.net

What is advisable

or

I have read some where that a lot of resources are consumed to open and close the database connection every time.

I need your advice


Solution

  • By default, MS SQL server uses connection pooling, so connections (using the exact same connection string) get assigned to a live connection kept in the pool by the server. You should open and close your connections to keep things tidy on your side.