Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Do you check connection on every call to SQL?
Message
 
 
À
05/03/2012 20:13:05
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2008
Divers
Thread ID:
01537347
Message ID:
01537350
Vues:
41
>>My application creates one SQL Server connection at the top of the application and then relies on it for all calls to SQL Server. But I understand that the connection can time out. Therefore, do you recommend that the program checks if the connection is still valid (by e.g. by SELECT CAST(1 as BIT) or some other way) every time the program needs to connect (to SQL Select or Update)? TIA.
>>
>>UPDATE. An idea just occurred to me. What if on every call to the SQL Server I store the time of the call to the application property. Then, every time another call needs to be made, the code would check how much time elapsed since the last call. Then if the time is greater than the set Time Out, create new connection, otherwise, use existing.
>>Does it make sense? Is it practical?
>
>I have Web sites with considerable amount of traffic and we hit SQL Server several millions times a week. With an enhance design since a while, I open and close the connection at every hit. SQL Server provides connection pooling. So, this is instant. There is no need to keep a connection alive. At least, from several infrastructures I have been supporting, either at Web, desktop or Web Service applications, this is the way I do it.

But isn't there a limit on how many connections user license allows? I don't know why and where I got that it is better practice to just open one connection and keep it for the duration of the application. Also, I would be concerned (if connecting on every hit) that it would slow down the application. But thank you for your input; something to consider.
"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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform