TAILIEUCHUNG - Adding, Updating, and Deleting Related Rows In this section, you'll learn how to make changes in

Adding, Updating, and Deleting Related Rows In this section, you'll learn how to make changes in DataTable objects that store rows from the Customers and Orders tables | Adding Updating and Deleting Related Rows In this section you ll learn how to make changes in DataTable objects that store rows from the Customers and Orders tables. These tables are related through the CustomerlD foreign key. As you ll see you must push changes to the underlying database tables in a specific order. If you don t your program will throw an exception. Note You ll find all the code examples shown in this section in the program. Setting Up the DataAdapter Objects You ll need two DataAdapter objects One to work with the Customers table which will be named customersDA. One to work with the Orders table which will be named ordersDA. Let s take a look at setting up these two DataAdapter objects. Setting Up the customersDA DataAdapter The following code creates and sets up a DataAdapter named customersDA that contains the necessary SELECT INSERT UPDATE and DELETE statements to access the Customers table SqlDataAdapter customersDA new SqlDataAdapter create a SqlCommand object to hold the SELECT SqlCommand customersSelectCommand SELECT CustomerlD CompanyName FROM Customers create a SqlCommand object to hold the INSERT SqlCommand customersInsertCommand customersInsertCommand. CommandText INSERT INTO Customers CustomerID CompanyName VALUES @CustomerID @CompanyName @CustomerID S 5 CustomerlD @CompanyName 40 CompanyName create a SqlCommand object to hold the UPDATE SqlCommand customersUpdateCommand UPDATE Customers SET CompanyName @NewCompanyName WHERE CustomerlD @OldCustomerID AND CompanyName @OldCompanyName @NewCompanyName 40 CompanyName @OldCustomerID 5 .

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.