TAILIEUCHUNG - Finding Rows in a DataView

[ Team LiB ] Recipe Finding Rows in a DataView Problem You need to find a row or group of rows in a DataView meeting certain criteria. Solution Use a sorted DataView to find rows using columns that are not part of the primary key. The sample code contains two event handlers: Sets up the sample by creating a DataTable containing the Orders table from the Northwind database. A DataView of the table sorted by the CustomerID and EmployeeID is created. Find Uses the FindRows( ) method of the DataView to retrieve the array of DataRowView objects. | Team LiB Recipe Finding Rows in a DataView Problem You need to find a row or group of rows in a DataView meeting certain criteria. Solution Use a sorted DataView to find rows using columns that are not part of the primary key. The sample code contains two event handlers Sets up the sample by creating a DataTable containing the Orders table from the Northwind database. A DataView of the table sorted by the CustomerlD and EmployeelD is created. Find Uses the FindRows method of the DataView to retrieve the array of DataRowView objects matching the CustomerlD and OrderlD specified. The code iterates over the collection to return the results. The C code is shown in Example 3-9. Example 3-9. File Namespaces variables and constants using System using using using using private DataView dv . . . private void DataViewSearchPerformanceForm_Load object sender e Fill the source table with schema and data. SqlDataAdapter da new SqlDataAdapter SELECT FROM Orders S ql_ConnectString DataTable dt new DataTable Orders dt dt Create the data view for the Orders table and sort. dv new DataView dt CustomerlD EmployeelD private void findButton_Click object sender e StringBuilder result new StringBuilder DataRowView foundRows Find the rows by the sort key value ProductID. try foundRows new object catch FormatException ex return Display the results. if 0 No rows found. else ORDER tREQUIRED DATE Iterate over the collection of found rows. foreach DataRowView row in foundRows row OrderID t row RequiredDate COUNT t .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.