PrepAway - Latest Free Exam Questions & Answers

Which code segment should you insert at line 02?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The
application retrieves data from a Microsoft SQL Server 2008 database named AdventureWorks. The
AdventureWorks.dbo.ProductDetails table contains a column named ProductImages that uses a
varbinary(max) data type. You write the following code segment. (Line numbers are included for
reference only.)
01 Dim reader As SqlDataReader = command.ExecuteReader(
02
03 )
04 While reader.Read()
05 pubID = reader.GetString(0)
06 …
07 stream = New FileStream()
08 writer = New BinaryWriter(stream)
09 startIndex = 0
10 retval = reader.GetBytes(1, startIndex, outByte, 0, bufferSize)
11 …
12 While retval = bufferSize
13 End While
14 writer.Write(outByte, 0, DirectCast(retval, Integer) – 1)
15 writer.Flush()
16 writer.Close()
17 stream.Close()
18 End While
You need to ensure that the code supports streaming data from the ProductImages column.
Which code segment should you insert at line 02?

PrepAway - Latest Free Exam Questions & Answers

A.
CommandBehavior.[Default]

B.
CommandBehavior.KeyInfo

C.
CommandBehavior.SingleResult

D.
CommandBehavior.SequentialAccess

Explanation:
Default
The query may return multiple result sets. Execution of the query may affect the database state.
Default sets no CommandBehavior flags, so calling ExecuteReader(CommandBehavior.Default)
is functionally equivalent to calling ExecuteReader().
KeyInfo The query returns column and primary key information. When KeyInfo is used for command
execution, the provider will append extra columns to the result set for existing primary key and
timestamp columns.
SingleResult The query returns a single result set.
SequentialAccess Provides a way for the DataReader to handle rows that contain columns with large
binary values.

Rather than loading the entire row, SequentialAccess enables the DataReader to load data as a
stream.
You can then use the GetBytes or GetChars method to specify a byte location to start the read
operation, and a limited buffer size for the data being returned.
CommandBehavior Enumeration
(http://msdn.microsoft.com/en-us/library/system.data.commandbehavior.aspx)


Leave a Reply