tailieunhanh - Sams Teach Yourself Database Programming with Visual C++ 6 in 21 Days phần 10

Được trang bị với những thông tin được cung cấp bởi các giao diện này lỗi, bạn đã sẵn sàng để trở về Các lỗi liên quan đến giao diện cuối cùng ngày hôm nay bao phủ là giao diện ISQLErrorInfo. Giao diện này được sử dụng con trỏ đối tượng tùy chỉnh lỗi của một bản ghi lỗi. Bạn truy cập vào giao diện ISQLErrorInfo bằng cách sử dụng phương pháp | Teach Yourself Database Programming with Visual C 6 in 21 days -- Day 21-OLE DB Error Handling The ISQLErrorInfo Interface Simpo PDF Merge and Split Unregistered Version - http The final error-related interface covered today is the ISQLErrorInfo interface. This interface is used in the custom error object pointer of an error record. You access the ISQLErrorInfo interface by using the GetCustomErrorObject method of the IErrorRecord interface. The ISQLErrorInfo interface defines a single method GetSQLInfo. This method is defined as follows HRESULT GetSQLInfo BSTR pSQLStateStr LONG plSQLErrorNum The pSQLStateStr parameter returns a string containing the current SQL state. The plSQLErrorNum returns the provider-specific SQL error number. The pSqlStateStr is an out bstr so the caller must free it by using SysFreeString. The Completed DispErrorInfo Source Code Armed with the information provided by these error interfaces you are ready to return to the DispErrorInfo procedure in Listing . The final procedure accesses the IErrorRecord interface and loops through each available error record one at a time. DispErrorInfo retrieves an IErrorInfo interface for each error record and uses that IErrorInfo interface to access the error description source and GUID. The GetCustomErrorObject is accessed for each record. If a ISQLErrorInfo interface is available the current SQL state and error number are also displayed. The complete DispErrorInfo procedure appears in Listing . NOTE Remember to use the SysFreeString method to release the returned string memory. The BSTR type is a Unicode type string. Refer to Day 19 Navigating the Result of a Query for more information about the methods available to process Unicode strings. Input Listing The Completed DISPERRORINFO Procedure 1 HRESULT DispErrorInfo IUnknown pErrorInt GUID ErrorIID 2 ISupportErrorInfo pSupportErrorInfo 3 IErrorInfo pErrorInfo 4 pErrorInfoRecord 5 IErrorRecords pErrorRecords 6 ISQLErrorInfo .