70-516 · Question #225
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 ObjectCache ( Id INT…
The correct answer is C. Dim obj As String = DirectCast(rdr(1), String). See the full explanation below for the reasoning.
Question
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 ObjectCache ( Id INT IDENTITY PRIMARY KEY, SerializedObjectData XML ) You write the following code segment to retrieve records from the ObjectCache table. (Line numbers are included for reference only.) 01Dim s As String = GetConnectStringFromConfigFile("xmldb") 02Using conn As New SqlConnection(s) 03Using cmd As New SqlCommand( 04"select * from ObjectCache", conn)) 06conn.Open() 07Dim rdr As SqlDataReader = cmd.ExecuteReader() 08While rdr.Read() 10DeserializeObject(obj) 11End While 12End Using 13End Using You need to retrieve the data from the SerializedObjectData column and pass it to a method named DeserializeObject. Which line of code should you insert at line 9?
Options
- ADim obj As XmlReader = DirectCast(rdr(1), XmlReader)
- BDim obj As SByte = DirectCast(rdr(1), SByte)
- CDim obj As String = DirectCast(rdr(1), String)
- DDim obj As Type = rdr(1).GetType()
How the community answered
(42 responses)- A7% (3)
- B17% (7)
- C71% (30)
- D5% (2)
Community Discussion
No community discussion yet for this question.