Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Already opened DataReader
Message
De
11/03/2011 12:58:07
 
 
À
11/03/2011 12:43:20
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01503339
Message ID:
01503371
Vues:
23
>>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
>
The fact that you have not yet experienced the problem with other connection types is no proof that you won't
But, more importantly, where will you close those connections ?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform