In the first part of our article, we uploaded a file and stored it in our
database. Now, we are going to stream binary data out of a database and to a browser client.
Refresher - Table Structure
Lets quickly refresh ourselves with the table structure we are using for storing images.
CREATE TABLE [dbo].[image] (
[img_pk] [int] IDENTITY (1, 1) NOT NULL ,
[img_name] [varchar] (50) NULL ,
[img_data] [image] NULL ,
[img_contenttype] [varchar] (50) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [dbo].[image] WITH NOCHECK ADD
CONSTRAINT [PK_image] PRIMARY KEY NONCLUSTERED
(
[img_pk]
) ON [PRIMARY]
GO
We have 4 columns in our sql server:
img_pk
- our Identity primary key.img_name
- the friendly name we are using for our imageimg_data
- the binary data field we are storing our image in.img_contenttype
- the Mime type of our image, for example: image/gif
Comments