PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

A Windows Forms application contains the following code segment.

string SQL = @"SELECT EmployeeID, LastName, FirstName, FROM Emloyees";
SqlDataAdapter da = new SqlDataAdapter(SQL, connStr); DataTable dt = new DataTable();
da.MissingSchemaAction = MissingSchemaAction.AddWithKey; SqlCommandBuilder bld = new SqlCommandBuilder(da);
da.Fill(dt);

The application allows the user to add rows to the data table. The application will propagate these additions to the database.
If the addition of any row fails, the other rows must still be added. The code must log how many new rows to be added.
You need to propagate the additions to the database and log a failed count. Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
da.ContinueUpdateError = true;
da.Update(dt);
DataTable dtError = dt.GetChanges(DataRowState.Unchanged);
Trace.WriteLine(dtErrors.Rows.Count.ToString() +
"rows not added.");

B.
da.ContinueUpdateOnError=false;
da.Update(dt);
DataTable dtError = dt.GetChanges(DataRowState.Unchanged);
Trace.WriteLine(dtErrors.Rows.Count.ToString() +
"rows not added.");

C.
da.ContinueUpdateError = true;
da.Update(dt);
DataRow[] rows = dt.GetErrors();
Trace.WriteLine(rows.Lenght.ToString() + "row not added.");

D.
da.ContinueUpdateOnError = false;
da.Update(dt);
DataRow[] rows = dt.GetErrors();
Trace.WriteLine(rows.Lenght.ToString() + "row not added.");


Leave a Reply