我已阅读此帖子的已接受答案:ExecuteReader 需要一个开放且可用的连接。连接的当前状态是 Connecting
我有一些存储在数据库表中的连接字符串。我正在考虑做这样的事情:
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
如果这会导致连接池机制出现问题,我正在徘徊,因为我有效地将一些逻辑封装在一个类中以连接到这些数据库。