>Hi,
>
>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.
See:
http://msdn.microsoft.com/en-us/library/8xx3tyca.aspxWhen you close a connection in code you will just be returning it to the pool. Likewise, when you open, you will usually be getting an existing connection from the pool.
Given the above it is usually best practice to keep a connection open in code for the minimum possible time - ideally wrap it in a using....