0

Ihave read the accepted answer to this post: ExecuteReader requires an open and available Connection. The connection's current state is Connecting

I have a few connection strings that are stored in a database table. I was thinking about doing something like this:

    Public class classConnection
       private con1 As dbConnection
       private strConnectionString As String
       private intType As Integer

    Public Sub New()
     con1 = New SQLConnection({connectionstring})
   End Sub

    Public Sub getConnectionStringByDescription()
      'Connect to con1 and get connection string
      'Set the connection string property
      'Set the database type e.g. Oracle
    End Sub

    Public Sub getConnectionStringByStatus()
      'Connect to con1 and get connection string
      'Set the database type e.g. Oracle
    End Sub

    Public Function getConnection() As dbConnection
       If intType=1 Then
            return New SQLConnection(strConnectionString)
       ElseIf intType=2 Then
            return New OracleConnection(strConnectionString)
       End If
    End Function

I am wandering if this will cause problems with the connection pool mechanism as I am effectively encapsulating some of the logic in a class for connecting to these databases.

Community
  • 1
  • 1
w0051977
  • 15,099
  • 32
  • 152
  • 329

1 Answers1

0

The instances of your class will not affect SQL server's abililty to pool connection strings. As long as the connection strings declare connection pooling and the connection strings are the same, SQL server will try to use current connections without creating new ones. See MSDN for more information.

Josh
  • 10,352
  • 12
  • 58
  • 109