nerdexam
Microsoft

70-516 · Question #183

The application populates a DataSet object by using a SqlDataAdapter object. You use the DataSet object to update the Categories database table in the database. You write the following code segment…

The correct answer is A. categoryRow.Delete(). DataRow.Delete() Deletes the DataRow.

Manipulating and Validating Data

Question

The application populates a DataSet object by using a SqlDataAdapter object. You use the DataSet object to update the Categories database table in the database. You write the following code segment. (Line numbers are included for reference only.) 01 SqlDataAdapter dataAdpater = new SqlDataAdapter("SELECT CategoryID, CategoryName FROM Categories", connection); 02 SqlCommandBuilder builder = new SqlCommandBuilder(dataAdpater); 03 DataSet ds = new DataSet(); 04 dataAdpater.Fill(ds); 05 foreach (DataRow categoryRow in ds.Tables[0].Rows) 06 { 07 if (string.Compare(categoryRow["CategoryName"].ToString(), searchValue, true) == 0) 08 { 09 ... 10 } 11 } 12 dataAdpater.Update(ds); You need to remove all the records from the Categories database table that match the value of the searchValue variable. Which line of code should you insert at line 09?

Options

  • AcategoryRow.Delete();
  • Bds.Tables[0].Rows.RemoveAt(0);
  • Cds.Tables[0].Rows.Remove(categoryRow);
  • Dds.Tables[0].Rows[categoryRow.GetHashCode()].Delete();

How the community answered

(56 responses)
  • A
    82% (46)
  • B
    4% (2)
  • C
    9% (5)
  • D
    5% (3)

Explanation

DataRow.Delete() Deletes the DataRow.

Topics

#DataSet#DataAdapter#DataRow deletion#row state

Community Discussion

No community discussion yet for this question.

Full 70-516 Practice