TAILIEUCHUNG - Refreshing a DataSet Automatically Using Extended Properties

Refreshing a DataSet Automatically Using Extended Properties Problem You need to automatically refresh a DataSet periodically. Solution Use extended properties and a timer. The sample code contains two event handlers and one method: | Team LiB Recipe Refreshing a DataSet Automatically Using Extended Properties Problem You need to automatically refresh a DataSet periodically. Solution Use extended properties and a timer. The sample code contains two event handlers and one method Sets up the sample by creating a DataTable containing the Categories table from the Northwind database. The default view of the table is bound to a data grid on the form. A second DataTable with the auto-refreshing functionality is created that also contains the Categories table from the Northwind database. The default view of the auto-refreshing table is bound to a second data grid on the form. An extended property RefreshTime is added to the auto-refreshing table and set to 15 seconds the value of the constant DATAREFRESH_SECONDS in the sample into the future. Finally a thread timer is created with a TimerClassback delegate CheckRefreshDataSet with a due time of one second and a period of one second. Update Uses a DataAdapter to update changes made to the first DataTable back to the data source. CheckRefreshDataSet This method is called periodically by the thread timer. The method checks whether the current time is later than the time in the RefreshTime extended property of the auto-refreshing table. If it is a DataAdapter is used to fill the table with the latest data from the data source and the RefreshTime extended property is once again set to 15 seconds into the future. The C code is shown in Example 9-17. Example 9-17. File Namespaces variables and constants using System using using using using private const String CATEGORIES_TABLE Categories private const int DATAREFRESH_SECONDS 15 private const int DATASETCHECKREFRESHINTERVAL_MS 1000 private DataTable dt dtRefresh private SqlDataAdapter da daRefresh private timer . private void AutomaticRefreshDataSetForm_Load

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.