Which code segment should you insert at line 07?

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 Orders(
ID numeric(18, 0) NOT NULL,
OrderNaroe varchac (50) NULL,
OrderTime time (7) NULL,
OrderDate dace NULL)
You write the following code to retrieve data from the OrderTime column. (Line numbers are
included for reference only.)
01 Dim conn As SqlConnection = New SqlConnection(“”*”)
02 conn.Open()
03 Dim cmd As SqlCommand = New SqlCommand(
“SELECT ID, OrderTime FROM Orders”, conn)
04 Dim rdr As SqlDacaReader = crod.ExecuteReader()
05
06 While rdr.Read()
07
08 End While
You need to retrieve the OrderTime data from the database. Which code segment should you insert
at line 07?

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 Orders(
ID numeric(18, 0) NOT NULL,
OrderNaroe varchac (50) NULL,
OrderTime time (7) NULL,
OrderDate dace NULL)
You write the following code to retrieve data from the OrderTime column. (Line numbers are
included for reference only.)
01 Dim conn As SqlConnection = New SqlConnection(“”*”)
02 conn.Open()
03 Dim cmd As SqlCommand = New SqlCommand(
“SELECT ID, OrderTime FROM Orders”, conn)
04 Dim rdr As SqlDacaReader = crod.ExecuteReader()
05
06 While rdr.Read()
07
08 End While
You need to retrieve the OrderTime data from the database. Which code segment should you insert
at line 07?

A.
Dim time As DateTime = DirectCast (rdr (1), DateTime)

B.
Dim time As TimeSpan = DirectCast(rdr(1), TimeSpan)

C.
Dim time As Timer = DirectCast(rdr(1), Timer)

D.
Dim time As String = DirectCast(rdr(1), String)

Explanation:
Pay attention to the fact that it goes about Microsoft SQL Server 2008 in the question.
Types date and time are not supported in Microsoft SQL Server Express.
time (Transact SQL)
(http://msdn.microsoft.com/en-us/library/bb677243.aspx)
Using date and time data
(http://msdn.microsoft.com/en-us/library/ms180878.aspx)
date and time functions
(http://msdn.microsoft.com/en-us/library/ms186724.aspx)
SQL Server Data Type Mappings (ADO.NET)
(http://msdn.microsoft.com/en-us/library/cc716729.aspx)



Leave a Reply 0

Your email address will not be published. Required fields are marked *