Which code segment should you insert at line 04?

You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET. The application uses a Microsoft SQL Server 2005 database.

The application contains a DataSet object that contains two DataTable objects. The DataTable objects reference the Customers and Orders tables in the database.
You write the following code segment. (Line numbers are included for reference only.)

01 DataSet custOrderDS = new DataSet();
02 custOrderDS.EnforceConstraints = true;
03 ForeignKeyConstraint custOrderFK = new ForeignKeyConstraint("CustOrderFK", custOrderDS.Tables["Customers"].Columns["CustomerID"], custOrderDS.Tables["Orders"].Columns["CustomerID"]);
04
05 custOrderDS.Tables["Orders"].Constraints.Add(custOrderFK);

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 04?

You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET. The application uses a Microsoft SQL Server 2005 database.

The application contains a DataSet object that contains two DataTable objects. The DataTable objects reference the Customers and Orders tables in the database.
You write the following code segment. (Line numbers are included for reference only.)

01 DataSet custOrderDS = new DataSet();
02 custOrderDS.EnforceConstraints = true;
03 ForeignKeyConstraint custOrderFK = new ForeignKeyConstraint("CustOrderFK", custOrderDS.Tables["Customers"].Columns["CustomerID"], custOrderDS.Tables["Orders"].Columns["CustomerID"]);
04
05 custOrderDS.Tables["Orders"].Constraints.Add(custOrderFK);

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 04?

A.
custOrderFK.DeleteRule = Rule.None;

B.
custOrderFK.DeleteRule = Rule.Cascade;

C.
custOrderFK.DeleteRule = Rule.SetNull;

D.
custOrderFK.DeleteRule = Rule.SetDefault;



Leave a Reply 0

Your email address will not be published. Required fields are marked *