1
Reply

When connection to database is failed, Which exception will be thrown?

Andrew

Andrew

Aug 17, 2011
8.9k
0

    It depends specifically on which one you use. The DataException class collects errors specific to ADO.NET components, and the SqlException class is used to capture messages specifically regarding SQL Server and ops in the System.Data.SqlClient classes. Depending on what you're specifically trying to do, you can attempt a connection in a try/catch block and throw specific information regarding the exception. See http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlexception.aspx for more information.

    Jon Guenther
    August 23, 2011
    0