PrepAway - Latest Free Exam Questions & Answers

Which type of object should you use in the method?

You need to write a method that retrieves data from a Microsoft Access 2013 database.
The method must meet the following requirements:
Be read-only.
Be able to use the data before the entire data set is retrieved.
Minimize the amount of system overhead and the amount of memory usage.
Which type of object should you use in the method?

PrepAway - Latest Free Exam Questions & Answers

A.
SqlDataAdapter

B.
DataContext

C.
DbDataAdapter

D.
OleDbDataReader

Explanation:
OleDbDataReader Class
Provides a way of reading a forward-only stream of data rows from a data source.
Example:
OleDbConnection cn = new OleDbConnection();
OleDbCommand cmd = new OleDbCommand();
DataTable schemaTable;
OleDbDataReader myReader;
//Open a connection to the SQL Server Northwind database.
cn.ConnectionString = “Provider=SQLOLEDB;Data Source=server;User ID=login;
Password=password;Initial Catalog=Northwind”;

2 Comments on “Which type of object should you use in the method?

  1. Lord Vader says:

    a datareader is a forward only resultset that remains connected to the database the entire time the reader is open. forward only means you can traverse only through the records once. you cannot move teh cursor back to a previous record.

    datatable is disconnected from teh db. you can move teh cursor back and forth. you can update data in the datatable, reconnect to the db and commit changes. a dataset is an obj used to populate the datatable and to reconnecct to the db.




    1



    0

Leave a Reply