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

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 that contains a Products table and an Inventory table.
The application coordinates updates between the records in the Products table and Inventory table by loading a DataSet class named DataSet1.

You write the following code segment.

DataColumn parentColumn = DataSet1.Tables["Products"].Columns["ProductID"];
DataColumn childColumn = DataSet1.Tables["Inventory"].Columns["ProductID"];

You need to ensure that the following requirements are met when the ProductID value is modified in the Products table:

The ProductID value is unique.
The records in the Inventory table are updated with the new ProductID value.

Which code segment should you add?

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?

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.

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

01 private void Update (SqlCommand cmdA, SqlCommand cmdB)
02 {
03 using (TransactionScope scope = new TransactionScope())
04 {
05
06 }
07 }

You need to execute the SqlCommand objects named cmdA and cmdB within a single distributed transaction.

Which code segment should you insert at line 05?

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("Customer");
dt.Columns.Add("ID", typeof(Int32));
dt.Columns.Add("State", typeof(String));
dt.Columns.Add("RegionCode", typeof(String));
dt.Rows.Add(1, "WA", "MT297EM");
dt.Rows.Add(2, "CA", "MT33SG");
dt.Rows.Add(3, "NY", "MT73229MP");

var query = from c in dt.AsEnumerable()
select c["RegionCode"];
foreach (string rNum in query)

You need to display only the digits from the RegionCode field.

Which line of code 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 uses the following LINQ query.

var query = from o in orderLinesQuery
where (string)o["CarrierTrackingNumber"] == "AEB6-4356-80"
select new
{
SalesOrderID = o.Field<int>("SalesOrderID"),
OrderDate = o.Field<DateTime>("OrderDate")
};

The CarrierTrackingNumber field in the DataRow is nullable. You need to ensure that an exception does not occur if the CarrierTrackingNumber field has a null value.

Which code segment should you use?

Which code segment should you insert at line 07?

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 private List<string> GetEmployers() {
02 List<string> employers = new List<string>();
03 SqlCommand cmd = new SqlCommand();
04 …
05 XmlReader reader = cmd.ExecuteXmlReader();
06 while (reader.Read()) {
07
08 }
09 return employers;
10 }

The cmd object returns the following XML data structure.

<Resume>
<Name>
<Name.First>Shai</Name.First>
<Name.Last>Bassli</Name.Last>
</Name>
<Employment>
<Emp.OrgName>Wingtip Toys</Emp.OrgName>

</Employment>

</Resume>

You need to populate the employers list with each employer entry in the XML data structure.

Which code segment should you insert at line 07?

Which code segment should you insert at line 02?

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

The application reads the following contacts.xml file.

<contacts>
<contact contactId="2">
<firstName>Don</firstName>
<lastName>Hall</lastName>
</contact>
<contact contactId="3">
<firstName>Simon</firstName>
<lastName>Rapier</lastName>
</contact>
<contact contactId="4">
<firstName>Shu</firstName>
<lastName>Ito</lastName>
</contact>
</contacts>

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

01 XDocument loaded = XDocument.Load(@"C:contacts.xml");
02
03 foreach (string name in q)
04 Console.WriteLine("{0}", name);

You need to ensure that the application outputs only the names Simon Rapier and Shu Ito.

Which code segment should you insert at line 02?

Which code segment should you insert at line 02?

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

The application contains a SqlDataAdapter object named daOrder. The SelectCommand property of the daOrder object is set.
You write the following code segment. (Line numbers are included for reference only.)

01 private void ModifyDataAdapter() {
02
03 }

You need to ensure that the daOrder object can also handle updates.

Which code segment should you insert at line 02?

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 table. A Web page of the application contains a GridView server control.
You write the following code segment. (Line numbers are included for reference only.)

01 private void LoadGrid()
02 {
03 using (SqlCommand command = new SqlCommand())
04 {
05 command.Connection = connection;
06 command.CommandText = "SELECT * FROM Customers";
07 connection.Open();
08
09 }
10 }

You need to retrieve the data from the database table and bind the data to the DataSource property of the GridView server control.

Which code segment should you insert at line 08?

Which code segment should you insert at line 16?

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

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

01 String myConnString = "User
02 ID=<username>;password=<strong password>;Initial
03 Catalog=pubs;Data Source=myServer";
04 SqlConnection myConnection = new
05 SqlConnection(myConnString);
06 SqlCommand myCommand = new SqlCommand();
07 DbDataReader myReader;
08 myCommand.CommandType =
09 commandType.Text;
10 myCommand.Connection = myConnection;
11 myCommand.CommandText = "Select * from Table1; Select * from Table2;";
12 int RecordCount = 0;
13 try
14 {
15 myConnection.Open();
16
17 }
18 catch (Exception ex)
19 {
20 }
21 finally
22 {
23 myConnection.Close();
24 }

You need to compute the total number of records processed by the Select queries in the RecordCount variable.

Which code segment should you insert at line 16?


Page 7 of 8« First...45678