PrepAway - Latest Free Exam Questions & Answers

Category: 70-561

Exam 70-561: TS: Microsoft .NET Framework 3.5, ADO.NET Application Development

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?

Which code segment should you use?

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

The application has an untyped DataTable object named tblCustomer.
The tblCustomer object contains a DataColumn named Age.

You plan to create a ColumnChanging event handler for the tblCustomer object. You need to ensure that when the existing data is modified, any value in the Age DataColumn that is greater than 100 is set to DBNull.

Which code segment should you use?

Which line of code should you insert at line 19?

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 adds data to a table named Customer. The Customer table has a primary key column.

You write the following code segment. (Line numbers are included for reference only.)

01 void ValidateData(DataTable tbl)
02 {
03 tbl.Columns.Add("IsValid", typeof(Boolean));
04 foreach (DataRow item in tbl.Rows)
05 {
06 //Set IsValid to true or false
07 }
08 }
09 DataTable ChangeData()
10 {
11 SqlDataAdapter adp = new SqlDataAdapter();
12 //Setup SqlDataAdapter to get Customer data
13 DataTable tblOriginal = new DataTable();
14 adp.FillSchema(tblOriginal, SchemaType.Source);
15 adp.Fill(tblOriginal);
16 //Change customer details
17 DataTable tblNew = tblOriginal.GetChanges();
18 ValidateData(tblNew);
19
20 return tblOriginal;
21 }

You need to ensure that the ChangeData method returns a DataTable that includes the value in the IsValid column for each row in the Customer table.

Which line of code should you insert at line 19?

Which code segment should you use?

You create an application by using the Microsoft .NET Framework version 3.5. You use Microsoft ADO.NET to access data for the application.

The application connects to a Microsoft SQL Server 2005 database. The database contains invoice records of customers in the Customer and Invoice tables.

You write the following code segment.

DataSet ds = new DataSet();
DataTable tblCust = ds.Tables.Add("Customer");
DataTable tblInv = ds.Tables.Add("Invoice");
DataColumn colPar = tblCust.Columns.Add("ID", typeof(int));
tblCust.Constraints.Add("PKey", colPar, true);
tblInv.Columns.Add("InvNo", typeof(string));
DataColumn colChild = tblInv.Columns.Add("CustomerID", typeof(int));
DataRow[] relatedRows;
//Retrieve data for Customer and Invoice

You need to retrieve the invoice details from the tblInv DataTable for customer records that have a value 1 in the ID column of the tblCust DataTable.

Which code segment should you use?


Page 4 of 8« First...23456...Last »