tailieunhanh - Beginning Visual Basic 2005 Databases phần 6

Sau khi tất cả các thông số đã được thêm vào bộ sưu tập các tham số, bạn gọi các phương pháp ExecuteStoredProcedure trong lớp cơ sở để thực hiện các thủ tục lưu trữ và thiết lập các kết quả của cuộc gọi chức năng này. Khối catch xử lý bất kỳ trường hợp ngoại lệ có thể được ném ra và trả về các trường hợp ngoại lệ cho người gọi: | Inserting Data After all the parameters have been added to the Parameters collection you call the ExecuteStoredProcedure method in the base class to execute the stored procedure and set the results of that call to this function. The CATCH block handles any exceptions that may be thrown and returns the exception to the caller Execute the stored procedure AddTimeSheet ExecuteStoredProcedure Catch ExceptionErr As Exception Throw New End Try End Function The WBLTimeSheets class is added next to the business logic component and implements the IDisposable interface just as the other classes in this component do. You add a private variable to represent the corresponding class in the data access component create the constructor and modify the Dispose procedure. Refer to the Try It Out exercise to review that. You ll be adding functions to this class in the next chapter when you start writing more complex SELECT statements in your stored procedures. Summary This chapter has taken a close look at data validation on all fronts. You did a little data validation in the client application when you validated that the ranking for a role was a numeric value. This demonstrated how you could perform data validation in the client application. You also did some data validation in the usp_InsertRole stored procedure which demonstrated how to perform data validation in a stored procedure which was more efficient than executing a separate stored procedure to determine if a ranking already existed before calling the stored procedure to insert data. The bulk of the data validation however was performed where it should be in the business logic component. Here you not only validate data to ensure that it conforms to the business rules but you also massage the data to remove blank spaces from it and set empty strings to NULL values. This increases the efficiency of your data storage in the database because there s no need to .

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