TAILIEUCHUNG - Performing a SQL SELECT Statement and Storing the Rows Locally phần 2

The Fill() method then creates a DataTable in the DataSet with the specified name and runs the SELECT statement. The DataTable created in your DataSet is then populated with the rows retrieved by the SELECT statement. | The Fill method then creates a DataTable in the DataSet with the specified name and runs the SELECT statement. The DataTable created in your DataSet is then populated with the rows retrieved by the SELECT statement. The following example calls the Fill method of mySqlDataAdapter passing myDataSet and Customers to the Fill method myDataSet Customers The Fill method creates a DataTable object named Customers in myDataSet and populates it with the rows retrieved by the SELECT statement. You can access these rows even when disconnected from the database. Step 11 Close the Database Connection Close the database connection using the Close method of the SqlConnection object created in the first step. For example Note Of course you don t have to immediately close the database connection before reading locally stored rows from your DataSet. I close the connection at this point in the example to show that you can indeed read the locally stored rows- even when disconnected from the database. Step 12 Get the DataTable Object From the DataSet Object Get the DataTable object created in step 10 from the DataSet object. You get a DataTable from your DataSet using the Tables property which returns a DataTableCollection object. To get an individual DataTable from your DataSet you pass the name of your DataTable in brackets Customers for example to the Tables property. The Tables property will then return your requested DataTable which you can store in a new DataTable object that you declare. In the following example Customers returns the Customers DataTable created in myDataSet in step 10 and stores the returned DataTable in myDataTable DataTable myDataTable Customers Note You can also specify the DataTable you want to get by passing a numeric value to the Tables property. For example 0 also returns the Customers DataTable. Step 13 Display the Columns for Each Row in the DataTable Display

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.