nerdexam
Microsoft

70-516 · Question #202

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. The application connects to a Microsoft SQL Server database. The application has two DataTable objects…

The correct answer is B. ordersFK.DeleteRule = Rule.None. None No action taken on related rows, but exceptions are generated. Cascade Delete or update related rows. This is the default. SetNull Set values in related rows to DBNull. SetDefault Set values in related rows to the value contained in the DefaultValue property. SetDefault…

Manipulating and Validating Data

Question

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. The application connects to a Microsoft SQL Server database. The application has two DataTable objects that reference the Customers and Orders tables in the database. The application contains the following code segment. (Line numbers are included for reference only.) 01 DataSet customerOrders = new DataSet(); 02 customerOrders.EnforceConstraints = true; 03 ForeignKeyConstraint ordersFK = new ForeignKeyConstraint("ordersFK", 04 customerOrders.Tables["Customers"].Columns["CustomerID"], 05 customerOrders.Tables["Orders"].Columns["CustomerID"]); 06 ... 07 customerOrders.Tables["Orders"].Constraints.Add(ordersFK); You need to ensure that an exception is thrown when you attempt to delete Customer records that have related Order records. Which code segment should you insert at line 06?

Options

  • AordersFK.DeleteRule = Rule.SetDefault;
  • BordersFK.DeleteRule = Rule.None;
  • CordersFK.DeleteRule = Rule.SetNull;
  • DordersFK.DeleteRule = Rule.Cascade;

How the community answered

(61 responses)
  • A
    3% (2)
  • B
    77% (47)
  • C
    13% (8)
  • D
    7% (4)

Explanation

None No action taken on related rows, but exceptions are generated. Cascade Delete or update related rows. This is the default. SetNull Set values in related rows to DBNull. SetDefault Set values in related rows to the value contained in the DefaultValue property. SetDefault specifies that all child column values be set to the default value. CHAPTER 1 ADO.NET Disconnected Classes Lesson 1: Working with the DataTable and DataSet Classes Cascading Deletes and Cascading Updates (page 26)

Topics

#ForeignKeyConstraint#DeleteRule#DataSet#referential integrity

Community Discussion

No community discussion yet for this question.

Full 70-516 Practice