Which line of code should you insert at line 08?
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.
You write the following code segment. (Line numbers are included for reference only.)
01 DataTable dt = new DataTable();
02 dt.Columns.Add("number");
03 dt.Columns.Add("string");
04 dt.Rows.Add(1, "3");
05 dt.Rows.Add(2, "2");
06 dt.Rows.Add(3, "1");
07 var result = from p in dt.AsEnumerable()
08
09 foreach (var number in result) {
10 Console.Write(number.ToString());
11 }
You need to display the string "321".
Which line of code should you insert at line 08?
Which line of code should you add?
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.
You write the following code segment.
DataTable dt = new DataTable("Strings");
dt = new DataTable();
dt.Columns.Add("Strings");
dt.Rows.Add("A-B");
dt.Rows.Add("C-D");
var c = from Strings in dt.AsEnumerable()
select Strings[0];
int count = 0;
You need to ensure that the value of the count variable is 4.
Which line of code should you add?
Which code segment should you add?
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.
The application contains two entities named Customer and Order. The Customer entity has a navigable property named Orders. The Orders property returns a collection of Order entity instances.
You write the following code segment.
ContosoEntities context = new ContosoEntities();
ObjectQuery<Customer> query;
You need to ensure that each time a Customer entity instance is queried the related Order entity instances are retrieved.
Which code segment should you add?
Which code segment should you use?
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET. The application connects to a Microsoft SQL Server 2005 database.
The application uses a strongly typed DataTable named Users that stores information about users. The application contains an import feature that returns a list of users. This list is stored in an untyped DataTable named newUsers. The column order and column types of the newUsers DataTable are same as that of the Users DataTable.
You need to copy the information from the newUsers DataTable to a typed DataTable named usersTable.
Which code segment should you use?
Which code segment should you insert at line 05?
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET. The application connects to a Microsoft SQL Server 2005 database.
The application uses a strongly typed DataSet named Products. The Products DataSet contains the following objects:
Two DataTables named Product and Retailer
A DataRelation named RetailerProduct
The DataRelation named RetailerProduct relates the Product DataTable to the Retailer DataTable.
A stored procedure named GetRetailerProducts returns two resultsets that contain the following two lists respectively:
A list of retailers
A list of products by each retailer
You write the following code segment. (Line numbers are included for reference only.)
01 Products dsProducts = new Products();
02 using (SqlDataAdapter da = new
03 SqlDataAdapter()){
04 da.SelectCommand = "GetRetailerProducts";
05
06 da.Fill(dsProducts);
07 }
You need to ensure that the resultsets from the stored procedure are correctly loaded into the DataTables.
Which code segment should you insert at line 05?
Which code segment should you insert at line 08?
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET. The application uses data from a Microsoft SQL Server 2005 database.
You write the following code segment. (Line numbers are included for reference only.)
01 public IDataReader GetCustomerReader()
02 {
03 SqlConnection con = new SqlConnection();
04 //Set up the connection
05 con.Open();
06 string sql = "Select * from Customers";
07 IDataReader rd = null;
08
09 con.Close();
10 return rd;
11 }
You need to ensure that a DataReader stream for the data in the Customers table can be returned from the GetCustomerReader method.
Which code segment should you insert at line 08?
Which code segment should you add?
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.
The application has the following typed DataSets:
A DataSet named DSCustomers with a DataTable named Customers
A DataSet named DSOrders with a DataTable named Orders
You write the following code segment.
DSCustomers dsCust = new DSCustomers();
DSOrders dsOrd = new DSOrders();
…
IDataReader rd;
You need to expose the Customers DataTable and the Orders DataTable by using a DataReader stream.
Which code segment should you add?
Which Code segment should you add?
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.
The application has a typed DataSet named DSOrders. The DSOrders DataSet has two DataTables as
shown in the following sequence:
1. Orders
2. Customers
You write the following code segment.
DSOrder ds = new DSOrders();
IDataReader rd;
You need to expose the two DataTables as a DataReader stream. You also need to ensure that the Customers DataTable is the first DataTable in the stream.
Which Code segment should you add?
Which code segment should you insert at line 14?
You create an application by using the Microsoft .NET Framework version 3.5. You use Microsoft ADO.NET to access the data for the application.
The application connects to a Microsoft SQL Server 2005 database that has a table named Customer. A secondary Microsoft Office Access database also has a table named Customer. Both the tables have the same schema. The data in the Access database is updated frequently.
You write the following code segment. (Line numbers are included for reference only.)
01 SqlConnection con = new SqlConnection();
02 //Setup con
03 string sql = "Select * from Customer";
04 SqlDataAdapter adp = new SqlDataAdapter(sql, con);
05 SqlCommandBuilder bld = new SqlCommandBuilder(adp);
06 DataTable tblCust = new DataTable();
07 adp.FillSchema(tblCust,SchemaType.Source);
08 adp.Fill(tblCust);
09 OleDbConnection conAc = new OleDbConnection();
10 OleDbCommand cmd = new OleDbCommand(sql, conAc);
11 //Setup conAc
12 conAc.Open();
13 IDataReader rd = cmd.ExecuteReader();
14
15 conAc.Close();
16 adp.Update(tblCust);
You need to merge the data from the Customer table of the Access database to the Customer table of the SQL Server 2005 database.
Which code segment should you insert at line 14?
Which code segment should you add?
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET. The application connects to a Microsoft SQL Server 2005 database.
You write the following code segment.
DataTable tbl = new DataTable();
tbl.Columns.Add("Price", typeof(double));
//Other columns added
//Fill data
You need to retrieve the maximum value in the Price column of the tbl DataTable.
Which code segment should you add?