Display Image From Database Table

W

Wayne Wengert

I am trying to build an ASP.NET application which includes the capability to
allow users to save pictures to a SQL Server 2000 database table and then
later to display selected photos (usually JPG files). I found some sample
code via a google search which showed how to upload a jpg file using ASP
(HtmlInputFile) and save it in an Access database and I've tried to adapt
that to work with ASP.NET/SQL Server and I am able to get the file data into
my SQL table (Hope it is valid?) My table structure is as follows:
============ Table Structure ====================
CREATE TABLE [UnitPhotos] (
[UnitID] [int] NOT NULL ,
[Filename] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[FileSize] [int] NULL ,
[ContentType] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[FileData] [image] NULL ,
CONSTRAINT [PK_UnitPhotos] PRIMARY KEY CLUSTERED
(
[UnitID]
) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
===================================================

The original Access version had a type of "OLE Object" for the "FileData"
field - I guessed that "image" was appropriate in SQL Server?

I have been able to upload an image file and save a row of data but now I am
looking for pointers to information on how to retrieve an image from that
table and display it. A sample of the data for the saved row is as follows:

UnitID - 235
FileName - myImage1.jpg
Filesize - 15671
ContentType - image/pjpeg
FileData - <Binary>

Any suggestions or pointer greatly appreciated.

Wayne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top