Which code segment should you use?
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The
application connects to a Microsoft SQL Server database. You load records from the Customers table
into a DataSet object named dataset. You need to retrieve the value of the City field from the first
and last records in the Customers table. Which code segment should you use?
You need to ensure that the application meets the following requirements: There is a SqlConnection named cn2 t
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The
application connects to two different Microsoft SQL Server 2008 database servers named Server1
and Server2. A string named sql1 contains a connection string to Server1. A string named sql2
contains a connection string to Server2.
01 using (TransactionScope scope = new
02 …
03 )
04 {
05 using (SqlConnection cn1 = new SqlConnection(sql1))
06 {
07 try{
08 …
09 }
10 catch (Exception ex)
11 {
12 }
13 }
14 scope.Complete();
15 }
You need to ensure that the application meets the following requirements:
There is a SqlConnection named cn2 that uses sql2.
The commands that use cn1 are initially enlisted as a lightweight transaction.
The cn2 SqlConnection is enlisted in the same TransactionScope only if commands executed by cn1
do not throw an exception.
What should you do?
Which code segment should you insert at line 04?
You use Microsoft .NET Framework 4 to develop an application that connects to a Microsoft SQL
Server 2008 database. You add the following stored procedure to the database.
CREATE PROCEDURE GetSalesPeople
AS
BEGIN
SELECT FirstName, LastName, Suffix, Email, Phone
FROM SalesPeople
END
You write the following code. (Line numbers are included for reference only.)
01SqlConnection connection = new SqlConnection(“& “);
02SqlCommand command = new SqlCommand(“GetSalesPeople”, connection);
03command.CommandType = CommandType.StoredProcedure;
04
You need to retrieve all of the results from the stored procedure.
Which code segment should you insert at line 04?
Which HTTP request should you use?
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create a Windows
Communication Foundation (WCF) Data Services service. You deploy the data service to the
following URL: http://contoso.com/Northwind.svc. You need to update the City property of the
Customer record that has its ID value as 123. You also need to preserve the current values of the
remaining properties. Which HTTP request should you use?
You need to ensure that entities can be sent to the service as XML
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. You
use Plain Old CLR objects (POCO) to model your entities.The application communicates with a
Windows Communication Foundation (WCF) Data Services service. You need to ensure that entities
can be sent to the service as XML. What should you do?
Which code segment should you insert at line 07?
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The
application uses the ADO.NET Entity Framework to model entities. You define a Category class by
writing the following code segment. (Line numbers are included for reference only.)
01 public class Category
02 {
03 public int CategoryID { get; set; }
04 public string CategoryName { get; set; }
05 public string Description { get; set; }
06 public byte[] Picture { get; set; }
07
08 }
You need to add a collection named Products to the Category class. You also need to ensure that the
collection supports deferred loading. Which code segment should you insert at line 07?
What should your model contain?
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application.The
application connects to a Microsoft SQL Server database. The Data Definition Language (DOL) script
of the database contains the following code segment.
CREATE TABLE [Sales].[SalesOrderHeader](
[SalesOrdedD] [int] IDENTITY(1,1)NOT NULL,
(BillToAddressID][int] NOT NULL,
…CONSTRAINT [PK_SalesOrderHeader_SalesOrder1D]
PRIMARY KEY CLUSTERED ([SalesOrder1D]ASC)
)ALTER TABLE [Sales].[SalesOrderHeader]
WITH CHECK ADD CONSTRAINT [FK_SalesOrderHeader_Address]
FOREIGN KEY{[BilIToAddressID])
REFERENCES [Person] [Address](AddressID])
You create an ADO.NET Entity Framework model. You need to ensure that the entities of the model
correctly map to the DDL of the database. What should your model contain?
Which connection string should you add to the app.config file?
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. You
use the ADO.NET Entity Framework to model your entities. The application connects to a Microsoft
SQL Server 2008 database named Adventure Works by using Windows Authentication. Information
about the required Entity Data Model (EDM) is stored in the following files:
• model.csdl
• model.ssdl
• model.msi
These files are embedded as resources in the MyCompanyData.dll file. You need to define the
connection string that is used by the application. Which connection string should you add to the
app.config file?
Which two actions should you perform?
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create a Wmdows
Communication Foundation (WCF) Data Services service. The service connects to a Microsoft SQL
Server 2008 database. The service is hosted by an internet Information Services (IIS) 6.0 server. You
need to ensure that applications authenticate against user information stored in the database
before the application is allowed to use the service. Which two actions should you perform? (Each
correct answer presents part of the solution. Choose two.)
Which code segment should you insert at line 02?
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create a Windows Forms
application. You plan to deploy the application to several shared client computers. You write the
following code segment. (Line numbers are included for reference only.)
01Configuration config = ConfigurationManager.OpenExeConfiguration(exeConfigName);
02
03config.Save();
04…
You need to encrypt the connection string stored in the .config file.
Which code segment should you insert at line 02?