Halloween Special Limited Time 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: ac4s65

You work as a Software Developer for ABC Inc.

You work as a Software Developer for ABC Inc. The company uses Visual Studio .NET 2005 as its application development platform. You are developing the data access component that all applications in your company intranet will use to access Microsoft SQL Server. You must include code to correctly catch and iterate through any number of errors that could be encountered when connecting to SQL Server. Which code segment should you choose?

A.

string connectionString =

"server=(local); database=Northwind;"

+ "integrated security=true;";

using (SqlConnection cnn = new SqlConnection(connectionString)){

try {

cnn.Open();

} catch (Exception ex) {

// handle the exception...

} catch (SqlException ex) {

foreach (SqlError error in ex.Errors) {

// handle the exception...

}

} finally {

// clean up

}

}

B.

string connectionString =

"server=(local); database=Northwind;"

+ "integrated security=true;";

using (SqlConnection cnn = new SqlConnection(connectionString)){

try {

cnn.Open();

} catch (SqlException ex) {

foreach (SqlError error in ex.Errors) {

// handle the exception...

}

} catch (Exception ex) {

// handle the exception...

} finally {

// clean up

}

}

C.

string connectionString =

"server=(local); database=Northwind;"

+ "integrated security=true;";

using (SqlConnection cnn = new SqlConnection(connectionString))}

try {

cnn.Open();

} catch (SqlException ex) {

switch (ex.Number) {

case 1:

// handle the exception...

break;

default:

// handle the exception...

break;

}

} catch (Exception ex) {

// handle

D.

string connectionString =

"server=(local); database=Northwind;"

+ "integrated security=true;";

using (SqlConnection cnn = new SqlConnection(connectionString)){

try {

cnn.Open();

} catch (SqlException ex) {

switch (ex.Number) {

case 1:

// handle the exception...

break;

default:

// handle the exception...

break;

}

} catch (Exception ex) {

// handle

GSSP-NET-CSHARP PDF/Engine
  • Printable Format
  • Value of Money
  • 100% Pass Assurance
  • Verified Answers
  • Researched by Industry Experts
  • Based on Real Exams Scenarios
  • 100% Real Questions
buy now GSSP-NET-CSHARP pdf
Get 65% Discount on All Products, Use Coupon: "ac4s65"