TAILIEUCHUNG - Microsoft SQL Server 2005 Developer’s Guide- P35

Microsoft SQL Server 2005 Developer’s Guide- P35: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 8 Developing Database Applications with ADO 319 error handler is fired enabling you to trap and respond to run-time errors. This tight integration with Visual Basic makes it easy to handle ADO errors. The following ShowError subroutine illustrates how ADO s error handling can be integrated with Visual Basic s On Error function Private Sub ShowError cn As Dim rs As New On Error GoTo ErrorHandler Select From no_such_table cn Exit Sub ErrorHandler DisplayADOError cn End Sub Here the ShowError function attempts to open a Recordset object against a nonexistent table. At the beginning of this function the On Error statement enables Visual Basic s error handler. In this case the On Error statement causes the program to branch to the ErrorHandler label when a trappable error is encountered. Executing the Open method with a nonexisting table causes the ADO object framework to generate a run-time error which in turn causes the program execution to resume with the first statement following the label. In this example the DisplayADOError subroutine is executed following the invalid Open attempt. The following code listing shows how the DisplayDAOError subroutine uses DAO s Error object and Errors collection to display information about an ADO error condition in a simple message box Private Sub DisplayADOError cn As Dim er As For Each er In MsgBox Number vbCrLf Source vbCrLf _ Text Next End Sub 320 Microsoft SQL Server 2005 Developer s Guide Figure 8-17 ADO error handling In this subroutine an ADO Connection object is passed in as a parameter. The ADO Errors collection is contained in the Connection object. Next a new ADO Error object named er is declared and a For Each loop iterates through the ADO Errors collection. The loop is required because the ADODB Errors collection can contain multiple Error objects where each Error object represents a .

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.