70-516 · Question #223
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application connects to a Microsoft SQL Server 2008 database. The database includes a database table…
The correct answer is A. Dim weight As var = reader.GetDouble(1). See the full explanation below for the reasoning.
Question
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application connects to a Microsoft SQL Server 2008 database. The database includes a database table named ProductCatalog as shown in the exhibit. (Click the Exhibit button.) You add the following code segment to query the first row of the ProductCatalog table. (Line numbers are included for reference only.) 01 Using cnx As var = New SqlConnection(connString) 02 Dim command As var = cnx.CreateCommand() 03 command.CommandType = CommandType.Text 04 command.CommandText = "SELECT TOP 1 * FROM dbo.ProductCatalog" 05 cnx.Open() 06 Dim reader As var = command.ExecuteReader() 07 If reader.Read() Then 08 Dim id As var = reader.GetInt32(0) 10 reader.Close() 11 End If 12 End Using You need to read the values for the Weight, Price, and Status columns. Which code segment should you insert at line 09?
Options
- ADim weight As var = reader.GetDouble(1)
- BDim weight As var = reader. GetDecimal (1)
- CDim weight As var = reader.GetDouble(1)
- DDim weight As var = reader.GetFloat(1)
How the community answered
(23 responses)- A78% (18)
- B4% (1)
- C13% (3)
- D4% (1)
Community Discussion
No community discussion yet for this question.