Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Already opened DataReader
Message
From
11/03/2011 12:43:20
 
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01503339
Message ID:
01503363
Views:
25
>I'm not sure that solution is going to work.
>Previously you were probably trying to make use of a connection that was still busy.
>Now you might be trying to close a connection that's still busy - which is just as bad...
>
>Bear in mind that there's very little extra overhead in creating a *new* connection providing that the connection string matches an existing pooled connection - testing as above showed that 10,000 'new' connections, by comparison, took 950 ms instead of 450.

You're right. Here is an updated version which takes care of that, but for SQLConnection only as I didn't experience that with OleDB provider as well as ODBC.
            ' 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
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform