The biggest drawback of storing binary data as a physical file is that your database easily can lose track of the binary data.
Notice that you have used the auto-implemented property syntax of C# to define the properties.
If you move your application from one server to another, you must manually ensure that physical files representing product images are shipped along with the rest of the application.
Also, any deletions to the database records also must be played on the physical image files.
To work through this example, you will need a SQL Server database with a table named Photos. Table 2: Schema of Photos table Notice that you have used the varbinary(MAX) data type for Photo column instead of the traditional Image data type.
You will now develop a web site that allows the users to add, modify, and delete individual records of the Photos table. If you wish, you can add a new database to its App_Data folder to create the Photos table. Listing 1: Properties of Photo class The Photo class has four public properties: Photo ID, Title, Description, and Photo Data.
Storing BLOBs directly inside SQL server provides the following advantages: In summary, depending on the application being developed, you should decide whether storing BLOB data in SQL Server is the way to go. To read BLOB data, you need to use the Sql Data Reader class of ADO. The use of Sql Data Reader class to read BLOB data can be best understood with an example.