Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 40 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
40
Dung lượng
847,79 KB
Nội dung
"Advanced Relational Data Management in NET" leads to another menu page that contains links to all the examples for this chapter: Accessing Complex Data The relational data access examples in the previous chapter were fairly simple, concentrating on extracting data from a single table and multiple tables into the DataSet and DataReader objects However, often the results we want are not just rows from a single table They may require a more complex SQL query that joins several tables, or they might be the result of running a stored procedure within the database In this section, we'll look at some examples that use both complex SQL statements and stored procedures to return sets of rows or just individual values from a data source The first shows how we can use a DataReader object to efficiently extract the data for display, and the second uses the DataSet object Accessing Complex Data with a DataReader We saw in the previous chapter how the DataReader object can be used to quickly and efficiently extract a rowset from a data store We simply create a Connection object, use it to create a Command object for this connection, and then call the ExecuteReader method of the Command object It returns the new DataReader object The example code, like many of the relational data access examples in the previous and in this chapter, uses a separate user control that exposes the specific connection strings for our database server We described this control in the previous chapter, and we insert it into our page using: