[Free] New Updated (October) Microsoft 70-516 Real Exam 81-90

Ensurepass

 

QUESTION 81

You need to fill a DataSet from the result that is returned by the stored procedure. The first result set must be added to a DataTable named Class, and the second result set must be added to a DataTable named Student. Which code segment should you use?

 

A.

DataSet ds = new DataSet ();

SqlDataAdapter ad = new SqlDataAdapter

(“GetClassAndStudents”, conn); ad.Fill(ds);

B.

DataSet ds = new DataSet();

SqlDataAdapter ad = new SqlDataAdapter

(“GetClassAndStudents”, conn); ds.Tables.Add(“Class”);

ds.Tables.Add(“Student”);

ad.Fill(ds);

C.

DataSet ds = new DataSet ();

SqlDataAdapter ad = new SqlDataAdapter

(“GetClassAndStudents”, conn);

ad.MissingMappingAction = MissingMappingAction.Ignore;

ad.Fill(ds, “Class”);

ad.Fill(ds, “Student”);

D.

DataSet ds = new DataSet ();

SqlDataAdapter ad = new SqlDataAdapter

(“GetClassAndStudents”, conn);

ad.TableMappings.Add(“Table”, “Class”);

ad.TableMappings.Add(“Tablel”, “Student”);

ad.Fill(ds);

 

Correct Answer: D

Explanation:

http://msdn.microsoft.com/en-us/library/ms810286.aspx

 

 

 

 

 

 

 

 

QUESTION 82

You use Microsoft .NET Framework 4 to develop an application that connects to a Microsoft SQL Server 2008 database. You add the following table to the database.

 

CREATE TABLE Orders(

 

ID numeric(18, 0) NOT NULL,

 

OrderName varchar(50) NULL,

 

OrderTime time(7) NULL,

 

OrderDate date NULL)

 

You write the following code to retrieve data from the OrderTime column. (Line numbers are included for reference only.)

 

01 SqlConnection conn = new SqlConnection (…) ;

 

02 conn.Open();

 

03 SqlCommand cmd = new SqlCommand(

 

“SELECT ID, OrderTime FROM Orders”, conn);

 

04 SqlDataReader rdr = cmd.ExecuteReader();

 

05

 

06 while(rdr.Read())

 

07 {

 

08

 

09 }

 

You need to retrieve the OrderTime data from the database.

 

Which code segment should you insert at line 08?

 

A.

TimeSpan time = (TimeSpan)rdr[1];

B.

Timer time = (Timer)rdr[1];

C.

string time = (string)rdr[1);

D.

DateTime time = (DateTime)rdr[1];

 

Correct Answer: A

Explanation:

Pay attention to the fact that it goes about Microsoft SQL Server 2008 in the question. Types date and time are not supported in Microsoft SQL Server Express.

time (Transact SQL)

http://msdn.microsoft.com/en-us/library/bb677243.aspx

Using date and time data

http://msdn.microsoft.com/en-us/library/ms180878.aspx

date and time functions

http://msdn.microsoft.com/en-us/library/ms186724.aspx

SQL Server Data Type Mappings (ADO.NET)

http://msdn.microsoft.com/en-us/library/cc716729.aspx

 

 

QUESTION 83

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. The application uses DataContexts to query the database.

 

You create a function that meets the following requirements:

 

clip_image002Updates the Customer table on the database when a customer is marked as deleted.

clip_image002[1]Updates the related entries in other tables (CustomerAddress, CustomerContacts) by marking them as deleted.

clip_image002[2]Prevents consumer code from setting the Deleted columns value directly.

 

You need to ensure that the function verifies that customers have no outstanding orders before they are marked as deleted.

 

You also need to ensure that existing applications can use the updated function without requiring changes in the code.

 

What should you do?

 

A.

Override the Delete operation of the DataContext object.

B.

Override the Update operation of the DataContext object.

C.

Modify the SELECT SQL statement provided to the DataContext object to use an INNER JOIN between the Customer and Orders tables.

D.

Add new entities to the DataContext object for the Customers and Orders tables.

 

Correct Answer: A

 

 

QUESTION 84

HOTSPOT

You use Microsoft .NET Framework 4 to create a data access layer component.

 

The component uses classes from the System.Data.SqlClient namespace to access data from a database by using connection pooling.

 

You need to ensure that support technicians can use Performance Monitor to monitor the number of free connections and active connections used by the component during run time.

 

What entry should you add to the switches element in the system.diagnostics section of the application configuration file?

 

To answer, select the appropriate options in the answer area.

 

clip_image003

 

Correct Answer:

clip_image004

 

 

QUESTION 85

DRAG DROP

You are developing an application that updates entries in a Microsoft SQL Server table named Orders. You need to ensure that you can update the rows in the Orders table by using optimistic concurrency.

 

What code should you use?

 

To answer, drag the appropriate properties to the correct locations. Each property may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.

 

clip_image006

 

Correct Answer:

clip_image008

 

 

QUESTION 86

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 add the following code segment. (Line numbers are included for reference only.)

 

01 var uri = new Uri(@”http://contoso.com/Northwind.svc/”);

 

02 var ctx = new NorthwindEntities(uri);

 

03 var categories = from c in ctx.Categories

 

04 select c;

 

05 foreach (var category in categories) {

 

06 PrintCategory(category);

 

07

 

08 foreach (var product in category.Products) {

 

09

 

10 PrintProduct(product);

 

11 }

 

12 }

 

You need to ensure that the Product data for each Category object is lazy-loaded.

 

What should you do?

 

A.

Add the following code segment at line 07.

ctx.LoadProperty(category, “Products”);

B.

Add the following code segment at line 09.

ctx.LoadProperty(product, “*”);

C.

Add the following code segment at line 07.

var strPrdUri = string.Format(“Categories({0})?$expand=Products”, category.CategoryID);

var productUri = new Uri(strPrdUri, UriKind.Relative); ctx.Execute<Product>(productUri);

D.

Add the following code segment at line 09.

var strPrdUri = string.Format(“Products?$filter=CategoryID eq {0}”, category.CategoryID);

var productUri = new Uri(strPrdUri, UriKind.Relative); ctx.Execute<Product>(productUri);

 

Correct Answer: A

Explanation:

LoadProperty(Object, String) Explicitly loads an object related to the supplied object by the specified navigation property and using the default merge option.

UriKind Enumeration

http://msdn.microsoft.com/en-us/library/system.urikind.aspx

RelativeOrAbsolute The kind of the Uri is indeterminate.

Absolute The Uri is an absolute Uri.

Relative The Uri is a relative Uri.

QUESTION 87

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application.

 

You create a stored procedure to insert a new record in the Categories table according to following code segment.

 

CREATE PROCEDURE dbo.InsertCategory

 

@CategoryName nvarchar(15),

 

@Identity int OUT

 

AS

 

INSERT INTO Categories (CategoryName) VALUES(@CategoryName)

 

SET @Identity = SCOPE_IDENTITY()

 

RETURN @@ROWCOUNT

 

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

 

01 private static void ReturnIdentity(string connectionString)

 

02 {

 

03 using (SqlConnection connection = new SqlConnection(connectionString))

 

04 {

 

05 SqlDataAdapter adapter = new SqlDataAdapter(

 

06 “SELECT CategoryID, CategoryName FROM dbo.Categories”,connection);

 

07 adapter.InsertCommand = new SqlCommand(“InsertCategory”, connection);

 

08 adapter.InsertCommand.CommandType = CommandType.StoredProcedure;

 

09 SqlParameter rowcountParameter = adapter.InsertCommand.Parameters.Add(

 

10 “@RowCount”, SqlDbType.Int);

 

11

 

12 adapter.InsertCommand.Parameters.Add(

 

13 “@CategoryName”, SqlDbType.NChar, 15, “CategoryName”);

 

14 SqlParameter identityParameter = adapter.InsertCommand.Parameters.Add(

 

15 “@Identity”, SqlDbType.Int, 0, “CategoryID”);

 

16

 

17 DataTable categories = new DataTable();

 

18 adapter.Fill(categories);

 

19 DataRow categoryRow = categories.NewRow();

 

20 categoryRow[“CategoryName”] = “New Beverages”;

 

21 categories.Rows.Add(categoryRow);

 

22 adapter.Update(categories);

 

23 Int32 rowCount = (Int32)adapter.InsertCommand.Parameters[“@RowCount”].Value;

 

24 }

 

25 }

 

You need to retrieve the identity of the new record. You also need to retrieve the row count.

 

What should you do?

 

A.

Insert the following code segment at line 11.

rowcountParameter.Direction = ParameterDirection.ReturnValue; Insert the following code segment at line 16.

identityParameter.Direction = ParameterDirection.ReturnValue;

B.

Insert the following code segment at line 11.

rowcountParameter.Direction = ParameterDirection.Output; Insert the following code segment at line 16.

identityParameter.Direction = ParameterDirection.Output;

C.

Insert the following code segment at line 11.

rowcountParameter.Direction = ParameterDirection.ReturnValue; Insert the following code segment at line 16.

identityParameter.Direction = ParameterDirection.Output;

D.

Insert the following code segment at line 11.

rowcountParameter.Direction = ParameterDirection.Output; Insert the following code segment at line 16.

identityParameter.Direction = ParameterDirection.ReturnValue;

 

Correct Answer: C

Explanation:

Input – The parameter is an input parameter.

InputOutput – The parameter is capable of both input and output.

Output – The parameter is an output parameter.

ReturnValue – The parameter represents a return value from an operation such as a stored procedure, builtin function, or user-defined function.

ParameterDirection Enumeration

http://msdn.microsoft.com/en-us/library/system.data.parameterdirection(v=vs.71).aspx

 

 

 

 

 

 

 

 

 

QUESTION 88

DRAG DROP

You are developing a Windows Forms application.

 

The application uses data from Microsoft SQL Server.

 

You have
the following code:

 

clip_image010

 

You need to identify the connection pools used by connections and connection?

 

What should you identify?

 

To answer, drag the appropriate configurations to the correct connections pools. Each configuration m be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.

 

clip_image012

 

Correct Answer:

clip_image014

 

 

QUESTION 89

You use Microsoft .NET Framework 4 to develop an application that uses LINQ to SQL.

 

The Product entity in the LINQ to SQL model contains a field named Productlmage. The Productlmage field holds a large amount of binary data.

 

You need to ensure that the Productlmage field is retrieved from the database only when it is needed by the application.

 

What should you do?

 

A.

Set the Update Check property on the Productlmage property of the Product entity to Never.

B.

Set the Auto-Sync property on the Productlmage property of the Product entity to Never.

C.

Set the Delay Loaded property on the Productlmage property of the Product entity to True.

D.

When the context is initialized, specify that the Productlmage property should not be retrieved by using DataLoadOptions

 

Correct Answer: C

Explanation:

Lazy loading is configured in the LINQ t

o SQL designer by selecting an entity and then, in the Properties window, setting the Delay Loaded property to true.The Delay Loaded property indicates that you want lazy loading of the column.

CHAPTER 4 LINQ to SQL

Lesson 1: What Is LINQ to SQL?

Eager Loading vs. Lazy Loading (page 254)

http://geekswithblogs.net/AzamSharp/archive/2008/03/29/120847.aspx

http://weblogs.asp.net/scottgu/archive/2007/05/29/linq-to-sql-part-2-defining-our-data-model-classes.aspx

 

 

QUESTION 90

You use Microsoft .NET Framework 4 to develop an ASP.NET Web application that connects to a Microsoft SQL Server 2008 database. The application uses Integrated Windows authentication in Internet Information Services (IIS) to authenticate users.

 

A connection string named connString defines a connection to the database by using integrated security.

 

You need to ensure that a SqlCommand executes under the application pool’ s identity on the database server.

 

Which code segment should you use?

 

A.

using (var conn = new SqlConnection())

{

conn.ConnectionString = connString;

SqlCommand cmd = null;

using (HostingEnvironment.Impersonate())

{

cmd = new SqlCommand(“SELECT * FROM BLOG”, conn); }

conn.Open();

var result = cmd.ExecuteScalar();

}

B.

using (var conn = new SqlConnection(connString)) {

var cmd = new SqlCommand (“SELECT * FROM BLOG, conn); conn.Open();

using(HostingEnvironment.Impersonate())

{

var result = cmd.ExecuteScalar();

}

}

C.

using (var conn = new SqlConneccion())

{

using (HostingEnvironroent.Impersonate())

{

conn.ConnectionString = connString;

}

var cmd = new SqlCommand(“SELECT * FROM BLOG, conn); conn.Open() ;

var result = cmd.ExecuteScalar();

}

D.

using (var conn = new SqlConnection())

{

conn.ConnectionString = connString;

var cmd = new SqlCommand(“SELECT * FROM BLOG”, conn);

using (HostingEnvironment.Impersonate())

{

conn.Open();

}

var result = cmd.ExecuteScalar();

}

 

Correct Answer: D

Free VCE & PDF File for Microsoft 70-516 Real Exam

Instant Access to Free VCE Files: MCSE|MCSA|MCITP…
Instant Access to Free PDF Files: MCSE|MCSA|MCITP…