Using Transaction Isolation Levels to Protect Data

[ Team LiB ] Recipe Using Transaction Isolation Levels to Protect Data Problem You want to effectively use transaction isolation levels to ensure data consistency for a range of data rows. Solution Set and use isolation levels as shown in the following example. | Team LiB Recipe Using Transaction Isolation Levels to Protect Data Problem You want to effectively use transaction isolation levels to ensure data consistency for a range of data rows. Solution Set and use isolation levels as shown in the following example. The sample code contains three event handlers Start Tran Opens a Connection and starts a transaction with the specified isolation level Chaos ReadCommitted ReadUncommitted RepeatableRead Serializable or Unspecified. Within the transaction a DataTable is filled with the Orders table from the Northwind database. The default view of the table is bound to the data grid on the form. Cancel Rolls back the transaction closes the connection and clears the data grid. Rolls back the transaction and closes the connection. The C code is shown in Example 6-30. Example 6-30. File Namespaces variables and constants using System using using using using private SqlConnection conn private SqlTransaction tran H . . . private void startButton_Click object sender e false Get the user-defined isolation level. IsolationLevel il if il else if il else if il else if il else if il else if il Open a connection. conn new SqlConnection S ql_ConnectString try Start a transaction. tran il catch Exception ex Could not start the transaction. Close the connection. Transaction .

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
44    310    2    14-05-2024
Đã 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.