0

This code, part of 1 method, will call 3 others methods

 .. 
    var userId = LookUpLocalUser(userName);

    if (userId == 0)
    {
        userId = InsertUser(userName, userName);

        AddRoleToUser(userId, (int)Roles.Admin);
        AddRoleToUser(userId, (int)Roles.User);

    }
    guid = LoginUser(userId);
..

Each of these methods (LookUpLoacalUser, AddToRole, LoginUser) will do something on the database. So my question is. What is better, to let each method open a connection to the database(and close it, using using) or should I open just one connection and pass it to each method?

Jepzen
  • 2,942
  • 6
  • 40
  • 62

1 Answers1

0

Yes, But make sure that you Close those connection at the end.

Balaji
  • 1,375
  • 1
  • 16
  • 30