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

Microsoft SQL Server 2005 Developer’s Guide- P12: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 3 Developing CLR Database Objects 89 capture any errors that may occur during the file import process. Within the Try-Catch loop a new StreamReader named stmReader is created that will be used to read the file from the operating system. The name of the file that will be read is passed into the StreamReader s instantiation call. Then the stmReader s ReadToEnd method is used to read the entire contents of the file into the sContent string variable. After the contents of the file have been read the stmReader StreamReader is closed and the contents of the sContents variable are assigned to the SQL Server column. If any errors occur while the input file is being read then the code in the Catch portion of the Try-Catch structure is executed. Within the Catch block a SqlPipe object named sp is created and then used to send those errors back to the caller of the stored procedure. This code block uses the SqlPipe object which represents a conduit that passes information between the CLR and the calling code. Here the SqlPipe object enables the stored procedure to pass error information to the external caller. Setting the Stored Procedure Security At this point the code is finished for the stored procedure but because of security concerns it still can t execute. By default SQL Server CLR objects can only access database resources and they cannot access external resources. In the case of the usp_ImportFile example the stored procedure needs to access the file system so the default security settings need to be changed. To enable external access you need to open the project s properties and click the Database tab. Then in the Permissions Level drop-down you need to change the value from Safe to External. More information about the CLR security options is presented later in this chapter. Deploying the Stored Procedure After the CLR stored procedure source code has been compiled into an assembly you can then add that assembly to the database and create the CLR stored .

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.