TAILIEUCHUNG - Retrieving New Identity Column Values

Retrieving New Identity Column Values The ProductID column of the Products table is an identity column. In this section, you'll see how to insert a new row into to Products table | Retrieving New Identity Column Values The ProductID column of the Products table is an identity column. In this section you ll see how to insert a new row into to Products table and retrieve the new value generated by the database for the ProductID identity column. Note You ll find a complete program named in the ch11 directory that illustrates the use of the methods shown in this section. This program listing is omitted from this book for brevity. In the examples assume you have a DataTable named productsDataTable that is populated with the rows retrieved by the following SELECT statement SELECT ProductID ProductName UnitPrice FROM Products ORDER BY ProductID The following example sets the PrimaryKey property of productsDataTable new DataColumn ProductID The next example sets the AllowDBNull AutoIncrement AutoIncrementSeed AutoIncrementStep ReadOnly and Unique properties for the ProductID DataColumn of productsDataTable DataColumn productIDDataColumn ProductID false true -1 -1 true true Because of these settings when you add a new DataRow to productsDataTable the ProductID DataColumn of your new DataRow will initially have the value -1. As in the earlier section Modifying Rows in a DataTable you need to set your DataAdapter object s InsertCommand UpdateCommand and DeleteCommand properties with appropriate Command objects. The CommandText property of the Command object used in the UpdateCommand property is as follows UPDATE Products SET ProductName @NewProductName UnitPrice @NewUnitPrice WHERE ProductID @OldProductID AND ProductName @OldProductName AND UnitPrice @OldUnitPrice The CommandText property of the Command object used in the .

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.