TAILIEUCHUNG - Using Stored Procedures to Add, Modify, and Remove Rows from the Database phần 2

Setting the InsertCommand Property of a DataAdapter The following example creates a SqlCommand object named myInsertCommand that contains a call to the AddProduct4() stored procedure | Setting the InsertCommand Property of a DataAdapter The following example creates a SqlCommand object named mylnsertCommand that contains a call to the AddProduct4 stored procedure SqlCommand mylnsertCommand EXECUTE @MyProductID AddProduct4 @MyProductName @MyUnitPrice @MyProductID 0 ProductID @MyProductID .Direction @MyProductName 40 ProductName @MyUnitPrice 0 UnitPrice As you can see from the previous code the direction of the @MyProductID parameter is set to which indicates that this parameter is an output parameter. Also the maximum length of the @MyProductID and @MyUnitPrice parameters is set to 0 in the third parameter to the Add method. Setting them to 0 is fine because the maximum length doesn t apply to fixed length types such as numbers only to types such as strings. Next the following example sets the InsertCommand property of mySqlDataAdapter to myInsertCommand myInsertCommand Setting the UpdateCommand Property of a DataAdapter The following example creates a SqlCommand object named myUpdateCommand that contains a call to the UpdateProduct stored procedure and sets the UpdateCommand property of mySqlDataAdapter to myUpdateCommand SqlCommand myUpdateCommand EXECUTE UpdateProduct @OldProductID @NewProductName @NewUnitPrice @OldProductName @OldUnitPrice @OldProductID 0 ProductID @NewProductName 40 ProductName @NewUnitPrice 0 UnitPrice @OldProductName 40 ProductName .

TÀI LIỆU MỚI ĐĂNG
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.