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
}
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.