1
Reply

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

Andrew

Andrew

13y
8.9k
0
Reply

    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.