Guest User

Untitled

a guest
Sep 24th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. public class SQL
  2. {
  3. SQL(ObjConn obj)
  4. {
  5. AbrirConexao(obj);
  6. }
  7.  
  8. public static void AbrirConexao(ObjConn objConn)
  9. {
  10. Conexao.ConnectionString = objConn.Acesso == "0" ? Utils.GetConnectionStringNerCard(objConn) : Utils.GetConnectionStringAutorizador(objConn);
  11. if (Conexao.State != ConnectionState.Open)
  12. Conexao.Open();
  13. }
  14. }
  15.  
  16. public void Dispose()
  17. {
  18. if (Conexao.State == ConnectionState.Open)
  19. Conexao.Close();
  20.  
  21. // outros códigos...
  22. }
  23.  
  24. using(SQL s = new SQL(ObjConn objConn))
  25. {
  26. // faça o que tiver que fazer aqui
  27. }
  28.  
  29. // após sair do contexto de 'using', o método Dispose será chamado automaticamente
Add Comment
Please, Sign In to add comment