Đang chuẩn bị liên kết để tải về tài liệu:
ASP.NET 4 Unleased - p 92

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Các SqlDataReader.NextResult () được gọi là để tạm ứng cho các tập kết quả tiếp theo. Phương thức này trả về hoặc là đúng hay sai tuỳ thuộc vào việc có tồn tại một tập kết quả tiếp theo. Trong Ví dụ 19,22, giả định rằng có cả một thể loại phim và resultset phim. Các trang trong Ví dụ 19,23 hiển thị nội dung của các bảng cơ sở dữ liệu hai trong hai GridView điều khiển (hình 19,10). | 884 CHAPTER 19 Building Data Access Components with ADO.NET DataLayerl.Movie newMovie new DataLayer1.Movie newMovie.Title string reader Title newMovie.Categoryld int reader CategoryID movies.Add newMovie static DataLayer1 _connectionString WebConfigurationManager.ConnectionStrings Movies .ConnectionString The SqlDataReader.NextResult method is called to advance to the next resultset. This method returns either True or False depending on whether a next resultset exists. In Listing 19.22 it is assumed that there is both a movies category and movies resultset. The page in Listing 19.23 displays the contents of the two database tables in two GridView controls see Figure 19.10 . O http locnlhost 1310 - Show Datai ayprl - Morilla Firefox Movie Categories Id Name 1 Adventure 3 Drama 4 Horror Movies Category Id Tide 3 Titanic 1 Star Wars 1 Jurassic Park 1 Jaws 3 host 3 Forrest Gump 2 Ice Age 2 Shrek 1 Independence Day 1 The Ring Done FIGURE 19.10 Displaying two resultsets. From the Library of Wow eBook Connected Data Access 885 LISTING 19.23 ShowDataLayerl.aspx @ Page Language C @ Import Namespace System.Collections.Generic DOCTYPE html PUBLIC - W3C DTD XHTML 1.0 Transitional EN http www.w3.org TR xhtml1 DTD xhtml1-transitional.dtd script runat server void Page_Load Get database data List DataLayer1.MovieCategory categories new List DataLayer1.MovieCategory List DataLayer1.Movie movies new List DataLayer1.Movie DataLayer1.GetMovieData categories movies Bind the data grdCategories.DataSource categories grdCategories.DataBind grdMovies.DataSource movies grdMovies.DataBind script html xmlns http www.w3.org 1999 xhtml head id Head1 runat server title Show DataLayer1 title head body form id form1 runat server div h1 Movie Categories h1 asp GridView id grdCategories Runat server h1 Movies h1 asp GridView id grdMovies Runat server 19 div form body html From the Library of Wow eBook 886 CHAPTER 19 Building Data Access Components with ADO.NET Working with Multiple Active Resultsets

TÀI LIỆU LIÊN QUAN
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.