Đang chuẩn bị liên kết để tải về tài liệu:
Using Stored Procedures to Add, Modify, and Remove Rows from the Database phần 2

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

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 mySqlConnection.CreateCommand mylnsertCommand.CommandText EXECUTE @MyProductID AddProduct4 @MyProductName @MyUnitPrice myInsertCommand.Parameters.Add @MyProductID SqlDbType.Int 0 ProductID myInsertCommand.Parameters @MyProductID .Direction ParameterDirection.Output myInsertCommand.Parameters.Add @MyProductName SqlDbType.NVarChar 40 ProductName myInsertCommand.Parameters.Add @MyUnitPrice SqlDbType.Money 0 UnitPrice As you can see from the previous code the direction of the @MyProductID parameter is set to ParameterDirection.Output 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 mySqlDataAdapter.InsertCommand 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 mySqlConnection.CreateCommand myUpdateCommand.CommandText EXECUTE UpdateProduct @OldProductID @NewProductName @NewUnitPrice @OldProductName @OldUnitPrice myUpdateCommand.Parameters.Add @OldProductID SqlDbType.Int 0 ProductID myUpdateCommand.Parameters.Add @NewProductName SqlDbType.NVarChar 40 ProductName myUpdateCommand.Parameters.Add @NewUnitPrice SqlDbType.Money 0 UnitPrice myUpdateCommand.Parameters.Add @OldProductName SqlDbType.NVarChar 40 ProductName myUpdateCommand.Parameters.Add .

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.