title: Multithreading and connection pool
body: <p>I have problems with asp.net web service that randomly getting errors like "sql transaction completed no longer usable", "transaction is already commited..."
  After read lot of posts I think its problem of shared connection problem bet I was unable to find where the problem is.
  Starting from 0 I want to create a "class for 2 porpuoses
  - Ensure Connections are closed
  - Coding less
  The simply class have 2 methods GDT (Give DataTable) and Ejecutar (execute in spanish)</p>
  
  <p>¿Can anybody tell me if this class is well designed for non having problems of sharing connections?</p>
  
  <pre><code>Public Class clsAccesoBD2
  
  Public Function GDT(ByVal strSql As String) As DataTable
      Try
          Using Cnn As New SqlConnection(ConfigurationManager.ConnectionStrings("CadenaPEA").ConnectionString)
              Using da As New SqlDataAdapter(strSql, Cnn)
                  Using dt As New DataTable
                      da.Fill(dt)
                      Return dt
                  End Using
              End Using
          End Using
      Catch ex As Exception
          'Log code here
  </code></pre>
  
  <p>Throw
          End Try
      End Function</p>
  
  <pre><code>Public Function Ejecutar(ByVal strSql As String) As Integer
      Try
          Using Cnn As New SqlConnection(ConfigurationManager.ConnectionStrings("CadenaPEA").ConnectionString)
              Using Cb As New SqlCommand(strSql, Cnn)
                  Dim RegistrosAfectados As Integer
                  Cnn.Open()
                  RegistrosAfectados = Cb.ExecuteNonQuery()
                  Cnn.Close()
                  Return RegistrosAfectados
              End Using
          End Using
      Catch ex As Exception
          'Log code here
          Throw
      End Try
  
  End Function
  </code></pre>
  
  <p>End Class</p>
  
  <p>este</p>