PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

A Windows Forms application contains the following code segment.

Dim SQL As String = “SELECT EmployeeID, LastName, FirstName FROM Employees” Dim da As New SqlDataAdapter(SQL, connStr)
Dim dt As New DataTable()
da.MissingSchemaAction = MissingSchemaAction.AddWithKey
Dim bld As 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 failed 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.ContinueUpdateOnError = Trueda.Update(dt)Dim dtErrors As DataTable = dt.GetChanges(DataRowState.Unchanged)Trace.WriteLine((dtErrors.Rows.Count.ToString() + ” rows not added.”))

B.
da.ContinueUpdateOnError = Falseda.Update(dt)Dim dtErrors As DataTable = dt.GetChanges(DataRowState.Unchanged)Trace.WriteLine((dtErrors.Rows.Count.ToString() + ” rows not added.”))

C.
da.ContinueUpdateOnError = Trueda.Update(dt)Dim rows As DataRow() = dt.GetErrors()Trace.WriteLine((rows.Length.ToString() + ” rows not added.”))

D.
da.ContinueUpdateOnError = Falseda.Update(dt)Dim rows As DataRow() = dt.GetErrors()Trace.WriteLine((rows.Length.ToString() + ” rows not added.”))


Leave a Reply