Retrieving Update Errors

[ Team LiB ] Recipe Retrieving Update Errors Problem You want to access all of the error information available after an update fails. Solution Use one of the available properties (such as HasErrors) and methods (such as GetErrors( )) to obtain the error information. | Team LiB Recipe Retrieving Update Errors Problem You want to access all of the error information available after an update fails. Solution Use one of the available properties such as HasErrors and methods such as GetErrors to obtain the error information. The schema of table TBL0215 used in this solution is shown in Table 2-14. Table 2-14. TBL0215 schema Column name Data type Length Allow nulls Uniqueld int 4 No NumericField int 4 No StringNoNullsField nvarchar 50 No ConstrainedNegativeField int 4 No The sample code contains two event handlers Sets up the sample by creating a table to demonstrate error information retrieval using a DataAdapter to fill it with sample data and adding it to a DataSet. The ContinueUpdateOnError property of the DataAdapter is set to true so that an exception is not raised if an error is encountered during an update. Finally the default view of the table is bound to the data grid on the form. Update Sets an error description for the first column of the first row using the SetColumnError method if the user has checked the Test Column Error check box. The Update method of the DataAdapter is called to update changes that the user has made to the data back to the database. After the update the HasErrors property of the DataSet is tested to determine if the DataSet has any errors. The collection of DataTable objects in the DataSet in this case there is only one is iterated again and the HasErrors property for each table is checked to see if the table has any errors. The collection of DataRow objects having errors in the table are accessed using the GetErrors method on the table. For each row in error the HasErrors property is checked to determine if the row has any errors and the RowError property of a row having errors is accessed to get the text describing the error. The collection of DataColumn objects having errors in the row are accessed using the row s GetColumnsInError method. For each column having an .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã 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.