How to check the database status on SQL Server

Couple of times, we came across situation (on N-Tier applications) where one has to make dynamic connection to different databases and sometime it may happen that you enter wrong database name or the database is offline or deleted.
In these cases, it is rather good to be check for the database status before waiting for server to respond in case of failures.
Continue here>>