Please consult the .NET Framework SDK docs as it has much better
information than I could provide:
ms-help://MS.NETFrameworkSDKv1.1/cpguidenf/html/cpconaccessingdatawithadonet.htm
But to quickly answer your question, for an MS SQL Server, for example:
try
{
using( SqlConnection con = new SqlConnection(conStr) )
{
con.Open();
// If you get here, it's successful
}
}
catch( SqlException se )
{
// If you get here, it wasn't
}