Kinh doanh - Marketing
Kinh tế quản lý
Biểu mẫu - Văn bản
Tài chính - Ngân hàng
Công nghệ thông tin
Tiếng anh ngoại ngữ
Kĩ thuật công nghệ
Khoa học tự nhiên
Khoa học xã hội
Văn hóa nghệ thuật
Sức khỏe - Y tế
Văn bản luật
Nông Lâm Ngư
Kỹ năng mềm
Luận văn - Báo cáo
Giải trí - Thư giãn
Tài liệu phổ thông
Văn mẫu
Giới thiệu
Đăng ký
Đăng nhập
Tìm
Danh mục
Kinh doanh - Marketing
Kinh tế quản lý
Biểu mẫu - Văn bản
Tài chính - Ngân hàng
Công nghệ thông tin
Tiếng anh ngoại ngữ
Kĩ thuật công nghệ
Khoa học tự nhiên
Khoa học xã hội
Văn hóa nghệ thuật
Y tế sức khỏe
Văn bản luật
Nông lâm ngư
Kĩ năng mềm
Luận văn - Báo cáo
Giải trí - Thư giãn
Tài liệu phổ thông
Văn mẫu
Thông tin
Điều khoản sử dụng
Quy định bảo mật
Quy chế hoạt động
Chính sách bản quyền
Giới thiệu
Đăng ký
Đăng nhập
0
Trang chủ
Công Nghệ Thông Tin
Quản trị mạng
Specifying Locking Hints in a SQL Server Database
Đang chuẩn bị liên kết để tải về tài liệu:
Specifying Locking Hints in a SQL Server Database
Thiên Phương
50
5
pdf
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
[ Team LiB ] Recipe 6.14 Specifying Locking Hints in a SQL Server Database Problem You need to pessimistically lock rows in an underlying SQL Server database. Solution Use SQL Server locking hints from ADO.NET. The sample code contains three event handlers | Team LiB Recipe 6.14 Specifying Locking Hints in a SQL Server Database Problem You need to pessimistically lock rows in an underlying SQL Server database. Solution Use SQL Server locking hints from ADO.NET. The sample code contains three event handlers Start Tran Button.Click Creates a SQL SELECT statement to retrieve the Orders table from the Northwind database. A locking hint either UPDLOCK or HOLDLOCK is added to the statement as specified. A Connection is opened and a Transaction started on it with an isolation level of ReadCommitted. A DataAdapter is used on the transacted connection to fill a DataTable. A CommandBuilder is created to generate updating logic. The default view of the table is bound to the data grid on the form. Cancel Button.Click Clears the data grid rolls back the transaction and closes the connection. Form.Closing Rolls back the transaction if it exists and closes the connection. The C code is shown in Example 6-39. Example 6-39. File UsingLockingHintsForPessimisticLockingForm.cs Namespaces variables and constants using System using System.Configuration using System.Data using System.Data.SqlClient private SqlConnection conn private SqlTransaction tran H . . . private void startButton_Click object sender System.EventArgs e startButton.Enabled false String sqlText SELECT FROM Orders WITH Add pessimistic locking as specified by user. if updLockRadioButton.Checked sqlText UPDLOCK else if holdLockRadioButton.Checked sqlText HOLDLOCK Create connection. conn new SqlConnection ConfigurationSettings.AppSettings S ql_ConnectString conn.Open Start the transaction. tran conn.BeginTransaction IsolationLevel.ReadCommitted Create the command. SqlCommand cmd new SqlCommand sqlText conn tran Create the DataAdapter and CommandBuilder. SqlDataAdapter da new SqlDataAdapter cmd SqlCommandBuilder cb new SqlCommandBuilder da Fill table using the DataAdapter. DataTable dt new DataTable da.Fill dt Bind the default view of the table to the grid. dataGrid.DataSource
TÀI LIỆU LIÊN QUAN
Specifying Locking Hints in a SQL Server Database
crossorigin="anonymous">
Đã 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.