PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You are creating a Windows Forms application by using the .NET Framework 3.5. You write a code segment to connect to a Microsoft Access database and populate a DataSet. You need to ensure that the application meets the following requirements:

* It displays all database exceptions.
* It logs all other exceptions by using the LogExceptionToFile.
Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
try{
categoryDataAdapter.Fill(dsCategory);
}catch (SqlException ex){
MessageBox.Show(ex.Message, “Exception”);
LogExceptionToFile(ex.Message);
}

B.
try{
categoryDataAdapter.Fill(dsCategory);
}catch (SqlException ex){
MessageBox.Show(ex.Message, “Exception”);
}catch (Exception ex){
LogExceptionToFile(ex.Message);}

C.
try{
categoryDataAdapter.Fill(dsCategory);
}catch (OleDbException ex){
MessageBox.Show(ex.Message, “Exception”);
}catch (Exception ex){
LogExceptionToFile(ex.Message);}

D.
try{
categoryDataAdapter.Fill(dsCategory);
}catch (OleDbException ex){
MessageBox.Show(ex.Message, “Exception”);
LogExceptionToFile(ex.Message);}


Leave a Reply