TAILIEUCHUNG - Using Auto-Incrementing Columns Without Causing Conflicts

[ Team LiB ] Recipe Using Auto-Incrementing Columns Without Causing Conflicts Problem You want to use an AutoIncrement column in a table without producing values that may be duplicated in records added by other users. Solution Use the AutoIncrementSeed and AutoIncrementStep properties of the AutoIncrement column. | Team LiB Recipe Using Auto-Incrementing Columns Without Causing Conflicts Problem You want to use an AutoIncrement column in a table without producing values that may be duplicated in records added by other users. Solution Use the AutoIncrementSeed and AutoIncrementStep properties of the AutoIncrement column. The sample code contains two event handlers Sets up the sample by creating a DataTable and programmatically defining the schema to match the Categories table in Northwind. The AutoIncrementSeed and AutoIncrementStep property values are both set to -1 for the AutoIncrement primary key column the CategoryID. A DataAdapter is created and used to fill the DataTable. The default view of the table is bound to the data grid on the form. Add Creates a new row in the Categories DataTable using the entered CategoryName and Description values and the automatically generated CategoryID field. The C code is shown in Example 4-1. Example 4-1. File Namespaces variables and constants using System using using using Table name constants private const String CATEGORIES_TABLE Categories Field name constants private const String CATEGORYID_FIELD CategoryID private const String CATEGORYNAME_FIELD CategoryName private const String DESCRIPTION_FIELD Description private DataTable dt . . . private void AutoIncrementWithoutConflictForm_Load object sender e Create the Categories table. dt new DataTable CATEGORIES_TABLE Add the identity column. DataColumn col CATEGORYID_FIELD typeof false true -1 -1 Set the primary key. new DataColumn col Add the other columns. col CATEGORYNAME_FIELD typeof false 15 DESCRIPTION_FIELD typeof Fill the table. .

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.