Which code segment should you use?
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application.
You use the ADO.NET Entity Framework Designer to model entities. The application includes two
ObjectContext instances named context1 and context2. You need to persist the changes in both
object contexts within a single transaction. Which code segment should you use?
You need to configure the application to connect to the database.
You use Microsoft .NET framework 4 to develop an application that connects to a Microsoft SQL
Serve 2008database named AdventureWorksLT. The database resides on an instance named INSTA
on a server named SQL01. You need to configure the application to connect to the database.
You need to retrieve all of the results from the stored procedure
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.)
01 Dim connection As SqlConnection = New SqlConnection(“& “)
02 Dim command As SqlCommand = New SqlCommand(“GetSalesPeople”, connection)
03 command.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 code segment should you insert at line 04?
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 application uses the following object
query to load a product from the database. (Line numbers are included for reference only.)
01 Using advWorksContext As New AdventureWorksEntities()
02 Dim productQuery As ObjectQuery(Of Product) =
03 advWorksContext.Product.Where(“it.ProductID = 900”)
04
05 End Using
You need to log the command that the query executes against the data source. Which code segment
should you insert at line 04?
You need to ensure that the actual exception data is provided to client computers
You use Microsoft Visual Studio 2010 and Microsoft NET Framework 4 to create an application. You
deploy a Windows Communication Foundation (WCF) Data Service to a production server. The
application is hosted by Internet Information Services (US). After deployment applications that
connect to the service receive the following error message. The server encountered an error
processing the request. See server logs for more details. You need to ensure that the actual
exception data is provided to client computers. What should you do?
Which code segment should you insert line 11?
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an app1ication. The
application connects to a Microsoft SQL Server database. You write the following code segment that
executes two commands against the database within a transaction. (Line numbers are included for
reference only)
01 Using connection As New SqlConnection(cnnStr)
02 connnectionOpen()
03 Dim sqlTran As SqlTransaction = connection.BeginTraraction()
04 Din command As Sqlcommand = connection Createcommand()
05 commandTransation = sqlTran
06 Try
07 command.CommandText = “INSERT INTO Production.ScrapReason(Name)
VALUES(‘Wrong size’)”
08 command.ExecuteNonQuery()
09 command.CommandText = “INSERT INTO Production ScrapReason(Name)
VALIES(’Wrong color’)”
10 command.ExecuteNonQuery()
11
12 End Using
You need to log error information if the transaction fails to commit or roll back. Which code segment
should you insert line 11?
You need to ensure that the application can detect all conflicts that occur between the offline customer infor
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 application uses Data Contexts to
query the database. The application meets the following requirements:
• Stores customer data offline
• Allows users to update customer records while they are disconnected tram the server
• Enables online changes to be submitted back to the SQL Server by using the Data Context
object
You need to ensure that the application can detect all conflicts that occur between the offline
customer information submitted to the SQL Server and the server version. You also need to ensure
that you can roll back local changes. What should you do?
Which code segment should you insert at line 03?
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. You
are creating the data layer of the application. You write the following code segment. (Line numbers
are included for reference only.)
01 Public Shared Function GetDataReader(sql As String) As SqlDataReader
02 Dim dr As SqlDataReader = Nothing
03
04 Return dr
05 End Function
You need to ensure that the following requirements are met:
The SqlDataReader returned by the GetDataReader method can be used to retrieve rows from the
database.
SQL connections opened within the GetDataReader method will close when the SqlDataReader is
closed. Which code segment should you insert at line 03?
Which code segment should you use?
You use Microsoft .NET Framework 4 to develop an ASP.NET application. The application uses
Integrated Windows authentication. The application accesses data in a Microsoft SQL Server 2008
database that is located on the same server as the application.
You use the following connection string to connect to the database.
Integrated Security=SSPI; Initial Catalog=Adventure¥orks;
The application must also execute a stored procedure on the same server on a database named
pubs.
Users connect to the ASP.NET application through the intranet by using Windows-based
authentication. You need to ensure that the application will use connection pooling whenever
possible and will keep the number of pools to a minimum. Which code segment should you use?
Which ObjectContext method should you call after changes are made to the entities?
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The
application connects to a Microsoft SQL Server 2008 database. You use the ADO.NET Entity
Framework to model your entities. You use ADO.NET self-tracking entities. You need to ensure that
the change-tracking information for the self-tracking entities can be used to update the database.
Which ObjectContext method should you call after changes are made to the entities?