TAILIEUCHUNG - Microsoft SQL Server 2005 Developer’s Guide- Part 23

Microsoft SQL Server 2005 Developer’s Guide- P23:SQL Server 2005 is a feature-rich release that provides a host of new tools and technologies for the database developer. This book is written to help database developers and DBAs become productive immediately with the new features and capabilities found in SQL Server 2005. | Chapter 6 Developing Database Applications with 199 functions would be considered part of the same logical transaction. From the database standpoint to ensure database integrity both the withdrawal and the deposit would be grouped together as a single transaction. If the withdrawal operation succeeded but the deposit failed the entire transaction could be rolled back which would restore the database to the condition it had before the withdrawal operation was attempted. Using transactions is an essential part of most production-level database applications. supports transactions using the Transaction classes. In order to incorporate transactions into your applications you first need to create an instance of the SqlTransaction object and then execute the BeginTransaction method to mark the beginning of a transaction. Under the covers this will cause the database server to begin a transaction. For instance using the SqlTransaction object to issue a BeginTransaction statement will send a T-SQL BEGIN TRANSACTION command to SQL Server. After the transaction has started the database update operations are performed and then the Commit method is used to actually write the updates to the target database. If an error occurs during the process then the RollBack operation is used to undo the changes. The following SQLCommandTransaction subroutine shows how to start a transaction and then either commit the results of the transaction to the database or roll back the transaction in the event of an error Private Sub SQLCommandTransaction cn As SqlConnection Dim cmd As New SqlCommand Dim trans As SqlTransaction Start a local transaction trans cn trans Try Insert a row transaction _ INSERT INTO Department VALUES 100 Transaction 100 This next insert will result in an error _ INSERT INTO Department VALUES 100 Transaction 101 .

TỪ KHÓA LIÊN QUAN
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.