My question may be stupid or may not be a question at all, but here it goes.
I perform some operations with the database in my project ASP.net MVC, where I create two objects each time, namely SqlConnectionand SqlCommand.
I showed an example below
using (SqlConnection connection = new SqlConnection(connectionString))
{
using (SqlCommand command = new SqlCommand("sRegisterUser", connection))
{
I perform all these different operations inside the same class with different methods.
My question is: how can I reduce the creation of these objects every time? How can I create them globally
PS: sRegisterUser is a stored procedure, since other other methods use different procedures that receive different values as parameters.
Please help me.
Thanks for any help in advance.