Click here to Skip to main content
15,896,348 members
Articles / Web Development / ASP.NET

Control to Display Binary Images in ASP.NET

Rate me:
Please Sign up or sign in to vote.
4.60/5 (12 votes)
31 Mar 2009CPOL1 min read 80.4K   1.9K   25  
The RbmBinaryImage control will help you display images directly from your database. You could bind the Image field directly to the ImageContent property, and also specify whether you want the display to be as a thumbnail and provide the thumbnail size.
��SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Test]') AND type in (N'U'))

BEGIN

CREATE TABLE [dbo].[Test](

	[TestId] [int] IDENTITY(1,1) NOT NULL,

	[TestName] [nvarchar](50) NULL,

 CONSTRAINT [PK_Test] PRIMARY KEY CLUSTERED 

(

	[TestId] ASC

)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

) ON [PRIMARY]

END

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ImageTest]') AND type in (N'U'))

BEGIN

CREATE TABLE [dbo].[ImageTest](

	[ImageId] [int] IDENTITY(1,1) NOT NULL,

	[ImageTitle] [nvarchar](50) NULL,

	[ImageContent] [image] NULL,

 CONSTRAINT [PK_ImageTest] PRIMARY KEY CLUSTERED 

(

	[ImageId] ASC

)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

END

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[InsertNewImageTest]') AND type in (N'P', N'PC'))

BEGIN

EXEC dbo.sp_executesql @statement = N'-- =============================================

-- Author:		<Author,,Name>

-- Create date: <Create Date,,>

-- Description:	<Description,,>

-- =============================================

CREATE PROCEDURE [dbo].[InsertNewImageTest]

	-- Add the parameters for the stored procedure here

	@ImageTitle nvarchar(50),

	@ImageContent image

AS

BEGIN

	Insert Into ImageTest ( ImageTitle,ImageContent) values (@ImageTitle,@ImageContent)

END

' 

END

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Egypt Egypt
Fun Coder Smile | :) My Job is my Hobby Smile | :)

Comments and Discussions