Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Build Your Own ASP.NET 2.0 Web Site Using CSharp And VB (2006) [eng]-1.pdf
Скачиваний:
142
Добавлен:
16.08.2013
Размер:
15.69 Mб
Скачать

12 Advanced Data Access

In the last three chapters, you learned some of the important concepts of data access and presentation. You learned how to use the SqlConnection class to establish a connection to the database, you learned how to use the SqlCommand class to execute a query on a database table, and you learned how to return the results of the command into an SqlDataReader for use within the application.

In this chapter, we’ll discuss the alternatives to using the SqlDataReader object for retrieving data from your database. For starters, it’s important to understand that SqlDataReader has both advantages and disadvantages. The two main points you need to keep in mind about SqlDataReader are:

SqlDataReader represents the fastest method available to read data from the data source.

SqlDataReader only allows read-only, forward-only access to data.

In other words, the SqlDataReader achieves very high performance at the cost of providing a direct connection to the data source. It doesn’t store the data locally, so after it reads one record and moves to the next one, there’s no way to go back. The SqlDataReader basically offers an input data stream, which you can read in the order in which it was sent, but which you are unable to modify.