PrepAway - Latest Free Exam Questions & Answers

Category: 70-516

Exam 70-516: TS: Accessing Data with Microsoft .NET Framework 4

What should you do?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application.
You use the ADO.NET Entity Framework Designer to model entities as shown in the following diagram.

You create an ObjectContext instance named objectContext1 and use it to create a SalesPerson instance named person1.
You create an ObjectContext instance named objectContext2 and use it to create a SalesTerritory instance named territory1.
You need to create and persist a relationship between person1 and terrotory1. What should you do?

What should you do?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application.
You use the Entity Framework Designer to create an Entity Data Model using model-first development.

The database has the following requirements:
* each table must have a datetime column named time_modified
* each table requires a trigger that updates the value of the time_modified column when a row is inserted or updated

You need to ensure that the database script that is created by using the Generate Database From Model option meets the requirements.
What should you do?

What should you add to the connection string?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application that connects
to a MS SQL server 2008 database by User Authentication. The application contains the following connection string:

SERVER=DBSERVER-01; DATABASE=pubs; uid=sa; pwd=secret;

You need to ensure that the password value in the connection string property of a SqlConnection object does not exist after is called.
What should you add to the connection string?

Which code elements needs to be added in the empty lines?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 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 navrchar(15),
@Identity int OUT
AS
INSERT INTO Categories(CategoryName) VALUES (@CategoryName)
SET @Identity = SCOPE_IDENTITY()
RETURN @@ROWCOUNT

You add the following code fragment. (Line numbers are included for reference only.)

01 private static void ReturnIdentity(string connectionString)
02 {
03 using(SqlConnection connection = new SqlConnection(connectionString))
04 {
05 SqlDataAdpater adapter = new SqlDataAdapter(“SELECT CategoryID, CategoryName FROM dbo.Categories”, connection);
06 adapter.InsertCommand = new SqlCommand(“InsertCategory”, connection);
07 adapter.InsertCommand.CommandType = CommandType.StoredProcedure;
08 SqlParameter rowcountParameter = adapter.InsertCommand.Parameters.Add(“@RowCount”, SqlDbType.Int);
09 …
10 adapter.InsertCommand.Parameters.Add(“@CategoryName”, SqlDbType.NChar, 15, “CategoryName”);
11 SqlParameter identityParameter = adapter.InsertCommand.Parameters.Add(“@Identity”, SqlDbType.Int, 0, “CategoryID”);
12 …
13 DataTable categories = new DataTable();
14 adapter.Fill(categories);
15 DataRow ctegoryRow = categories.NewRow();
16 categoryRow[“CategoryName”] = “New beverages”;
17 categories.Rows.Add(categoryRow);
18 adapter.Update(categories);
19 Int32 rowCount = (Int32)adapter.InsertCommand.Parameters[“@RowCount”].Value;
20 }
21 }

Which code elements needs to be added in the empty lines?

Which code segment should you insert at the empty phrase in line 01?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application.
The application retreives data from Microsoft SQL Server 2008 database named AdventureWorks.
The AdventureWorks.dbo.ProductDetails table contains a column names ProductImages that uses a varbinary(max) data type.

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

01 SqlDataReader reader = command.ExecureReader(– empty phrase here –);
02 while(reader.Read())
03 {
04 pubID = reader.GetString(0);
05 stream = new FileStream(…);
06 writer = new BinaryWriter(stream);
07 startIndex = 0;
08 retval = reader.GetBytes(1, startIndex, outByte, 0, bufferSize);
09 while(retval == bufferSize)
10 {
11 …
12 }
13 writer.Write(outbyte, 0, (int)retval-1);
14 writer.Flush();
15 writer.Close();
16 stream.Close();
17 }

You need to ensure that the code supports streaming data from the ProductImages column.
Which code segment should you insert at the empty phrase in line 01?

What are two possible code segments that you can use to achieve the goal?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application.
The application connects to a Microsoft SQL Server 2008 database. You add the following store procedure to the database.

CREATE PROCEDURE GetProducts
AS
BEGIN
SELECT ProductID, Name, Price, Cost
FROM Product
END

You create a SqlDataAdapter named adapter to execute the stored procedure. You need to fill a DataTable instance with the first 10 rows of the result set.
What are two possible code segments that you can use to achieve the goal?

Which code segment should you insert at line 04?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application.
The application contains the following XML document:

<bib>
<book title=”TCP/IP Illusrated” year=”1994″>
<author>Author1</author>
</book>
<book title=”Programming in UNIX” year=”1992″>
<author>Author1</author>
<author>Author2</author>
<author>Author3</author>
</book>
<book title=”Data on the web” year=”2000″>
<author>Author4</author>
<author>Author3</author>
</book>
</bib>

You add the following code fragment. (Line numbers are included for reference only.)

01 public IEnumerable<XElement> GetBooks(string xml)
02 {
03 XDocument doc = XDocument.Parse(xml);
04 …
05 }

You need to return a list of book XML element that are authored by Author1. Which code segment should you insert at line 04?


Page 9 of 19« First...7891011...Last »