Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Too many connections opened creates a failure
Message
De
15/12/2011 14:32:15
 
 
À
15/12/2011 14:29:33
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:
01531136
Message ID:
01531144
Vues:
39
>Since OledbConnection implements IDisposable the simplest and safest way is the wrap the whole thing in a USING.... ENDUSING block......

This is what I had for a while for the SQL Client. And, today, for the OleDb, I adjusted to verify and close it. From that code, is Using/End Using applicable for OleDb as well:
                        ' Different backends handle it differently
                        Select Case nSQLMode

                            ' OleDb
                            Case 1
                                nResult = oDataAdapter.SelectCommand.ExecuteNonQuery()

                                ' If the connection was not already opened
                                If Not lConnectionIsAlreadyOpened Then

                                    ' Close the connection
                                    oCommand.Connection.Close()

                                End If

                                ' SQLClient
                            Case 2

                                Using loSQLConnection As New SqlConnection(oApp.aConnection(nConnectionString, 1))
                                    loSQLConnection.Open()
                                    oCommand.Connection = loSQLConnection
                                    nResult = oDataAdapter.SelectCommand.ExecuteNonQuery()
                                End Using

                                ' ODBC
                            Case 3
                                nResult = oDataAdapter.SelectCommand.ExecuteNonQuery()

                        End Select
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform