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?

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?

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 0

Your email address will not be published. Required fields are marked *