Question 3


Question

Multiple Choices

You are developing a card game for F54 with the following code segment.

The GetAnimals() method must meet the following requirements:

  1. Connect to a Microsoo SQL Server database.
  2. Create Animal objects and populate them with data from the database.
  3. Return a sequence of populated Animal objects.
Which two actons should you perform? (Each correct answer presents part of the soluton. Choose two.)

  • A. Insert the following code segment at line 16:
    while(sqlDataReader.NextResult())
  • B. Insert the following code segment at line 13:
    sqlConnecton.Open())
  • C. Insert the following code segment at line 13:
    sqlConnecton.BeginTransacton())
  • D. Insert the following code segment at line 16:
    while(sqlDataReader.GetValues())
  • E. Insert the following code segment at line 16:
    while(sqlDataReader.Read())

Answer:

BD
Explanation
SqlConnecton.Open - Opens a database connecton with the property setngs specifed by the ConnectonString.

SqlDataReader.Read - Advances the SqlDataReader to the next record.