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 17:01:31
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2008
Divers
Thread ID:
01537347
Message ID:
01538002
Vues:
24
>>This is where the query happens:
>>
>>
>>                                Using loSQLConnection As New SqlConnection(lcConnectionString)
>>                                    oCommand.Connection = loSQLConnection
>>                                    oDataAdapter.Fill(oDataSet)
>>                                End Using
>>
>
>Do you usually close the connection? And if yes, how? The last segment of your code shows that you call Fill() method to fill the dataset. But this, if I understand correctly, leaves the connection open. How do you deal with this?


Dmitry, I thought Viv already mentioned that to you: If .Fill() is called and the Connection is already open, it is left open after the filling the DataTable. If the Connection is not open, ADO.NET will open it, fill the DataTable and then close the Connection.

So, in the above code snippet, since it's a new Connection, the Connection will be closed automatically.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform