Which of the following code segments will he use to accomplish this task?

Posted by: Pdfprep Category: GSSP-.NET Tags: , ,

Allen works as a Software Developer for Mansoft Inc. He develops an application using Visual Studio .NET 2005. The application connects to a SQL Server database using a SqlConnection object named NewConnection. Allen creates a few stored procedures in the database. Sometimes an error occurs, when a user executes stored procedures. Allen wants to add an error-handling code to the application to handle errors that occur on executing stored procedures.

Which of the following code segments will he use to accomplish this task?
A . try
{
NewConnection.Open();
}
catch(DBConcurrencyException exep)
{
//Error-handling code
}
B . try
{
NewConnection.Open();
}
catch(SqlException exep)
{
//Error-handling code
}

C . try
{
NewConnection.Open();
}
catch(DataException exep)
{
//Error-handling code
}
D . try
{
NewConnection.Open();
}
catch(InvalidCastException exep)
{
//Error-handling code
}

Answer: B

Leave a Reply

Your email address will not be published.