This documentation is archived and is not being maintained.

How to: Display Pictures from a Database in Windows Forms

In Windows applications, you can use the Data Sources Window to bind images in a database to appear in a PictureBox control.


Any other controls that are available to your project that support data binding and can display images can be used in place of the PictureBox.

Items in the Data Sources window that are stored as byte arrays (pictures in a database are typically stored as byte arrays) have their control type set to None by default. Because byte arrays can contain anything from a simple array of bytes to the executable file of a large application, you must set the control for displaying byte-array columns based on your actual data. For columns that contain pictures, set that column's drop type to PictureBox from that item's control list. For more information, see How to: Set the Control to be Created when Dragging from the Data Sources Window.

The following procedure assumes that the Data Sources window is already populated with an item that is bound to your image. For more information, see How to: Connect to Data in a Database.

To bind pictures in a database to a PictureBox control

  1. In the Data Sources window, expand the desired table or object type to display its columns or properties.

  2. Select the column or property that contains your image data, and from its control list, choose PictureBox.


    Your form must be opened in the designer for the control drop-down lists to appear in the Data Sources window.