The following example constructs an HTTP header for an image and then uses the binary information from an image field in SQL Server to provide a GIF to the browser.
<%@ LANGUAGE="VBSCRIPT" %>
' Clear out the existing HTTP header information
Response.Expires = 0
Response.Buffer = TRUE
' Change the HTTP header to reflect that an image is being passed.
Response.ContentType = "image/gif"
Set cn = Server.CreateObject("ADODB.Connection")
' The following open line assumes you have set up a System DataSource
' by the name of myDSN.
'Remember to change the following connection string parameters to reflect the correct values
'for your SQL server.
cn.Open "DSN=myDSN;UID=<username>;PWD=<strong password>;DATABASE=pubs"
Set rs = cn.Execute("SELECT logo FROM pub_info WHERE pub_id='0736'")
This page will display the image New Moon Books from a SQL Server
This technique can also be applied to other types of binary data, not just graphics. The browser needs to know what type of content is being presented. Do this by specifying the proper mime type in the Response.ContentType variable. For example, if you wanted to view a word document, you would set the ContentType = "application/msword".