70-516 · Question #61
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application that connects to a Microsoft SQL Server 2008 database. You add the following table to the database…
The correct answer is C. String obj = (String)rdr[1]. See the full explanation below for the reasoning.
Question
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 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 retreive records from the ObjectCache table. (Line numbers are included for reference only.) 01 string s = GetConnectionStringFromConfigFile("xmldb"); 02 using (SqlConnection conn = new SqlConnection(s)) 03 using (SqlCommand cmd = new SqlCommand("select * from ObjectCache", conn)) 04 { 05 conn.Open(); 06 SqlDataReader rdr = cmd.ExecuteReader(); 07 while(rdr.Read()) 08 { 09 ... 10 DeserializeObject(obj); 11 } 12 } You need to retreive the data from the SerializedObjectData column and pass it to a method named DeserializeObject. Which line of code should you insert at line 09?
Options
- AXmlReader obj = (XmlReader)rdr[1];
- BSByte obj = (SByte)rdr[1];
- CString obj = (String)rdr[1];
- DType obj = (Type)rdr[1];
How the community answered
(37 responses)- A3% (1)
- B5% (2)
- C76% (28)
- D16% (6)
Community Discussion
No community discussion yet for this question.