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?
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)