PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.

You write the following code segment.

DataTable tbl = new DataTable();
DataColumn colId = tbl.Columns.Add("ID", typeof(int));
colId.AutoIncrement = true;
tbl.Constraints.Add("Pkey", colId, true);
DataColumn colCtry = tbl.Columns.Add("Country", typeof(string));
colCtry.DefaultValue = "USA";
tbl.Columns.Add("Name", typeof(string));

You need to create a new row in the tbl DataTable that meets the following requirements:

The ID column is set to an auto-incremented value.
The Country column is set to the default value.
The Name column is set to the value "Customer A".

Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
tbl.Rows.Add(0, null, "Customer A");

B.
tbl.Rows.Add(null, null, "Customer A");

C.
tbl.Rows.Add(null, DBNull.Value, "Customer A");

D.
tbl.Rows.Add(DBNull.Value, DBNull.Value, "Customer A");


Leave a Reply