Here's I wrote some code to insert\retrieve images from SQL Server database
1- Create table to hold Image ID, Name and itself
USE [ImagesDatabase]
GO
/****** Object: Table [dbo].[Image] Script Date: 07/10/2009 23:46:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Image](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Caption] [nvarchar](50) NOT NULL,
[Content] [varbinary](max) NOT NULL,
CONSTRAINT [PK_Image] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
2- Create stored procedure to insert new image
CREATE PROC InsertNewImage
@Caption varchar(50),
@Content varbinary(max)
AS
INSERT INTO [DummyDatabase].[dbo].[Image] ([Caption], [Content])
VALUES (@Caption, @Content)
3- Create stored procedure to get image by ID
CREATE PROC GetImageByID
@ID int
AS
SELECT Caption, Content FROM Image WHERE ID = @ID