17.07.2015 Views

The Art of SQL Server FILESTREAM - Red Gate Software

The Art of SQL Server FILESTREAM - Red Gate Software

The Art of SQL Server FILESTREAM - Red Gate Software

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 5: <strong>FILESTREAM</strong> with ASP.NET and SilverlightLab 6: Creating a Web Handler to Serve Imagesfrom a <strong>FILESTREAM</strong> DatabaseIn Lab 4, we saw how to upload files into the <strong>FILESTREAM</strong> column <strong>of</strong> a <strong>SQL</strong> <strong>Server</strong>database from a web page. In this lab, we will see how to serve those files back to theclient applications, upon request.We will create a web page to retrieve images from the database and send them to theclient browser. A web page is not the best way to implement such a handler, but at thisstage we want to minimize complexity, so that we can focus on <strong>FILESTREAM</strong> and noton ASP.NET features. In a later lab, we will develop a similar solution using a generichandler, which is a much better approach.To do this, we will:• create a stored procedure to retrieve the <strong>FILESTREAM</strong> information• create the web page that serves item images• run and test the application.Creating a stored procedure to retrieve<strong>FILESTREAM</strong> dataStart by creating a stored procedure that will retrieve the logical path name <strong>of</strong> the<strong>FILESTREAM</strong> value, and the <strong>FILESTREAM</strong> transaction context. This stored procedure,shown in Listing 5-9, will take an item number as input parameter and will return the<strong>FILESTREAM</strong> information.189

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!