Which two actions should you perform?

You are developing an application that includes the following code segment. (Line numbers
are included for reference only.)

The GetCustomers() method must meet the following requirements:
Connect to a Microsoft SQL Server database.
Populate Customer objects with data from the database.
Return an IEnumerable<Customer> collection that contains the populated Customer objects.
You need to meet the requirements.
Which two actions should you perform? (Each correct answer presents part of the solution.
Choose two.)

You are developing an application that includes the following code segment. (Line numbers
are included for reference only.)

The GetCustomers() method must meet the following requirements:
Connect to a Microsoft SQL Server database.
Populate Customer objects with data from the database.
Return an IEnumerable<Customer> collection that contains the populated Customer objects.
You need to meet the requirements.
Which two actions should you perform? (Each correct answer presents part of the solution.
Choose two.)

A.
Insert the following code segment at line 17:
while (sqlDataReader.GetValues())

B.
Insert the following code segment at line 14:
sqlConnection.Open();

C.
Insert the following code segment at line 14:
sqlConnection.BeginTransaction();

D.
Insert the following code segment at line 17:
while (sqlDataReader.Read())

E.
Insert the following code segment at line 17:
while (sqlDataReader.NextResult())

Explanation:
sqlConecction.Open in line 14
The SqlConnection.Open method opens a database connection with the property settings
specified by the ConnectionString.
while (SqlDataReader.Read()) in line 17
Read the next line until end of file.

The SqlDataReader.Read method Advances the SqlDataReader to the next record.
The value is true if there are more rows; otherwise false.



Leave a Reply 3

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


Fippy Darkpaws

Fippy Darkpaws

reader.NextResult is wrong because that is used when reader has more than one result set (SP or inline SQL has more than one Select).

ASV

ASV

3 and 53 almost the same.