TAILIEUCHUNG - Microsoft ADO .NET 4 Step by Step - p 9

56 Microsoft ADO .NET 4 Step by Step 3. Locate the CustomerAccounts_RowChanging event handler, which is called whenever any value in a row changes within the CustomerAccounts table. Add the following code, which checks for valid data involving multiple columns: If (() = True) Then If (CBool(("Active", )) = True) And (IsDBNull(("StartDate", )) = True) Then = "Active accounts must have a valid start date." End If End If 4. Run the program. Use its features to create, edit, and delete data rows. When you attempt to provide invalid data—incorrect data types, violations of business rules, duplicate account names—the program provides the appropriate. | 56 Microsoft 4 Step by Step 3. Locate the CustomerAccounts_RowChanging event handler which is called whenever any value in a row changes within the CustomerAccounts table. Add the following code which checks for valid data involving multiple columns If True Then If CBool Active True And IsDBNull StartDate True Then Active accounts must have a valid start date. End If End If 4. Run the program. Use its features to create edit and delete data rows. When you attempt to provide invalid data incorrect data types violations of business rules duplicate account names the program provides the appropriate error messages. Summary This chapter discussed the DataRow class the final destination of all data in . With one instance created per data record the DataRow class manages each individual columnar field. When used alone its stored values use the generic Object data type but when inserted into a DataTable object s Rows collection all data type limitations and other constraints established for the table s columns act together to verify the row s content. Beyond these column settings you can add event handlers to the DataTable that apply custom business rules to the column and row data providing an additional layer of validation and ultimately integrity for the table s data. Chapter 3 Storing Data in Memory 57 Chapter 3 Quick Reference To Do This Add a row to a DataTable Use the DataTable object s NewRow method to obtain a DataRow instance. Update the Item values in the DataRow as needed. Add the row using the table s method. Delete a row from a DataTable Call the DataRow object s Delete method. Call the DataTable object s AcceptChanges method. Check for data issues in new and modified DataRow objects Create a DataTable. Add DataColumn definitions as needed. Add event handlers for the DataTable object s ColumnChanging RowChanging or other

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.