' If the connection is already opened If lConnectionIsAlreadyOpened Then ' The following lines have been updated to support a SQL Server issue with the use of the SQLDataReader ' related objects to bug once in every hundreds of thousands of SQL requests. When that happens, this ' creates a message like "There is already an open DataReader associated with this Command which must be closed first." ' Get the proper definition as per the current scope If oProcess Is Nothing Then ' Different backends handle it differently Select Case nSQLMode ' OleDb Case 1 oCommand.Connection = oApp.aConnection(nConnectionString, 2) ' SQLClient Case 2 oCommand.Connection = New SqlConnection(oApp.aConnection(nConnectionString, 1)) oCommand.Connection.Open() ' ODBC Case 3 oCommand.Connection = oApp.aConnection(nConnectionString, 2) End Select Else ' Different backends handle it differently Select Case nSQLMode ' OleDb Case 1 oCommand.Connection = oProcess.aConnection(nConnectionString, 2) ' SQLClient Case 2 oCommand.Connection = New SqlConnection(oProcess.aConnection(nConnectionString, 1)) oCommand.Connection.Open() ' ODBC Case 3 oCommand.Connection = oProcess.aConnection(nConnectionString, 2) End Select End If