I am about to publish my first website, and I am kinda worried about SqlCommand
and SqlConnection
objects, they take too much space in the memory and might really overwhelm the server.
What's the best method to implement a light and fast SQL query execution method? I know that we need to use 'using' statement for the SqlCommand
object in order to garbage collector handle it better, but what about SqlConnection
? Should I keep my SqlConnection
object in a session storage per user, or make a static SqlConnection
object for the whole appdomain?
Should I keep my SqlCommand
objects per page or make a SqlCommand
for every event and close it with cmd.Dispose();
or not even bother because it will be disposed when it leaves the local section.
I just wanted to have an expert's opinion about this subject.
Thanks in advance