Mastering Microsoft Visual Basic 2010 phần 8

không định kiểu DataSets. Trong chương sau, tôi sẽ thảo luận chi tiết trong DataSets gõ và làm thế nào để sử dụng chúng trong xây dựng dữ liệu bị ràng buộc các ứng sử dụng DataSets trong ứng dụng của bạn, trước tiên bạn phải tạo ra một đối tượng DataAdapter, | STORING DATA IN DATASETS 703 untyped DataSets. In the following chapter I ll discuss in detail typed DataSets and how to use them in building data-bound applications. The DataAdapter Class To use DataSets in your application you must first create a DataAdapter object which is the preferred technique for populating the DataSet. The DataAdapter is nothing more than a collection of Command objects that are needed to execute the various SQL statements against the database. As you recall from our previous discussion we interact with the database by using four different command types one to select the data and load them to the client computer with the help of a DataReader object a Command object with the SELECT statement and three more to submit to the database the new rows a Command object with the INSERT statement update existing rows a Command object with the UPDATE statement and delete existing rows a Command object with the DELETE statement . A DataAdapter is a container for Connection and Command objects. If you declare a SqlDataAdapter object with a statement like the following Dim DA As New SqlDataAdapter you ll see that it exposes the properties described in Table . Table SqlDataAdapter object properties PROPERTY DESCRIPTION InsertCommand A Command object that s executed to insert a new row UpdateCommand A Command object that s executed to update a row DeleteCommand A Command object that s executed to delete a row SelectCommand A Command object that s executed to retrieve selected rows Each of these properties is an object and has its own Connection property because each may not act on the same database as unlikely as it may be . These properties also expose their own Parameters collection which you must populate accordingly before executing a command. The DataAdapter class performs the two basic tasks of a data-driven application It retrieves data from the database to populate a DataSet and submits the changes to the database. To populate a DataSet use

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã 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.