Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Do you check connection on every call to SQL?
Message
 
 
À
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:
01538009
Vues:
25
>>>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.

Ok, I misunderstood what Viv said. Thank you for your explanation.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform