tailieunhanh - Beginning C# 2005 Databases From Novice to Professional phần 9

vì vậy khi bạn gọi phương thức ExecuteReader, bạn sẽ có được một ngoại lệ, như thể hiện trong hình 13-2. Mặc dù nó là một ngoại lệ xử lý dứt điểm, nó vẫn cung cấp cho bạn một chẩn đoán chính xác ExecuteReader: CommandText tài sản có | CHAPTER 15 WORKING WITH EVENTS 391 Table 15-1. Common Events Object Event Delegate Remarks SqlDataAdapter RowUpdating SqlRowUpdatingEventHandler Raised before the row is updated in the database. The event handler receives a SqlRowUpdatingEventArgs object. SqlDataAdapter RowUpdated SqlRowUpdatedEventHandler Raised after a row is updated in the database. The event handler receives a SqlRowUpdatedEventArgs object. SqlDataAdapter FillError FillErrorEventHandler Raised when the Fill method is called. The event handler receives a FillErrorEventArgs object. DataRow Columnchanging DataColumnChangeEventHandler Raised when the data in a data column is changing. The handler receives a DataColumnChangeEventArgs object. DataRow ColumnChanged DataColumnChangeEventHandler Raised after a value has been changed for the specified data column in a data row. The handler receives a DataColumnChangedEventArgs object. DataTable RowChanging DataRowChangeEventHandler Raised when a data row is changing. The event handler receives a DataChangeEventArgs object. DataTable RowChanged DataRowChangeEventHandler Raised after a data row has changed. The event handler receives a DataChangeEventArgs object. DataTable RowDeleting DataRowChangeEventHandler Raised before a data row is deleted. The event handler receives a DataRowChangeEventArgs object. DataTable RowDeleted DataRowChangeEventHandler Raised after a data row is deleted. The event handler receives a DataRowChangeEventArgs object. Try It Out Using RowUpdating and RowUpdated Events Let s experiment with the SQL Server data adapter s RowUpdating and RowUpdated events in this example you ll see how they re raised and handled when a value in a dataset changes 392 CHAPTER 15 WORKING WITH EVENTS 1. Insert the code in Listing 15-5 into the click event handler for the third button. Listing 15-5. button3_Click clear list box create connection SqlConnection conn new SqlConnection @ data source . sqlexpress