Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Do you check connection on every call to SQL?
Message
De
11/03/2012 14:44:59
 
 
À
10/03/2012 14:45:38
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2008
Divers
Thread ID:
01537347
Message ID:
01537989
Vues:
30
>I was speaking in general terms - it's obviously not a good idea to call .Dispose() on an item that will remain in scope and, on that basis, I've never consiously done so (I'd rather not give unexpected behaviour a chance :-} ).
>Can you show an example of how you are using an SqlDataAdapter in a using block ?

Some declarations:
        Public oDataSet As DataSet = Nothing
        Private oCommand As IDbCommand = Nothing
        Private oDataAdapter As IDbDataAdapter = Nothing
Based on the backend, I have this:
            ' Different backends handle it differently
            Select Case nSQLMode

                ' OleDb
                Case 1
                    oDataAdapter = New OleDbDataAdapter
                    oCommand = New OleDbCommand

                    ' SQLClient
                Case 2
                    oDataAdapter = New SqlDataAdapter
                    oCommand = New SqlCommand

                    ' ODBC
                Case 3
                    oDataAdapter = New OdbcDataAdapter
                    oCommand = New OdbcCommand

            End Select
Some initializations:
                oCommand.CommandText = tcSQL
                oDataAdapter.SelectCommand = oCommand

                oDataSet = New DataSet
This is where the query happens:
                                Using loSQLConnection As New SqlConnection(lcConnectionString)
                                    oCommand.Connection = loSQLConnection
                                    oDataAdapter.Fill(oDataSet)
                                End Using
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform