April 22, 2005

Images from SQL Server database in ASP.NET DataGrid

Here it goes...

Create a Table in SQL DB as follows
Images ( imgid int IDENTITY (1, 1) NOT NULL , imgdata image NULL)

Create a asp.net web page with DataGrid and databound with this table results
(make image as template column) add a img tag with this url "imagedatapipe.aspx?id=" Binder... (ID) in page load of this imagedatapipe page..

con.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader()
dr.Read()
Dim bindata() As Byte = dr.GetValue(1)
Response.BinaryWrite(bindata)

(MAKE SURE imagedatapipe PAGE IS BLANK AND DOES NOT CONTAIN ANY DATA -
optionaly u can clear response stream and Dont forget to add few data in table :)

8 comments:

Anonymous said...

Nice. Thank you for the info. - SV ( http://sv.typepad.com/guju )

Mobile Offers said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
alex said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.