home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 9 / IOPROG_9.ISO / contrib / iis4 / iis4_07.cab / Blob_VBScript.asp < prev    next >
Encoding:
Text File  |  1997-09-04  |  1.7 KB  |  62 lines

  1. <% @ LANGUAGE=VBScript    %>
  2. <% Option Explicit        %>
  3.  
  4. <!--#include file="adovbs.inc"-->
  5.  
  6. <%
  7.     ' This sample utilizes the Image field in the PUB_INFO table.  
  8.     ' This table is installed with Microsoft SQL Server in the
  9.     ' PUBS database.
  10.     
  11.     ' To run this sample, you must first do the following:
  12.     '
  13.     '            1) Go to the System Control Panel
  14.     '            2) Open the OBDC Control Panel 
  15.     '            3) Select the System DSN Tab and Add a Source
  16.     '            4) Choose the SQL Server Driver and hit Finish
  17.     '            5) Name the Source "IISSDK", enter the name of the local server
  18.     '            6) Setup Security (Note: If you have setup a password on the
  19.     '               SQL Server, you may have to change the example below)
  20.     '            7) Set the Default Database to the pubs db that comes with SQL
  21.  
  22.  
  23.     Dim oConn        
  24.     Dim oRs        
  25.     Dim Pic        
  26.     Dim PicSize        
  27.     
  28.  
  29.     ' Setup HTTP Header Information so that the browser interprets
  30.     ' the returned data as a gif graphic file.  Note that browsers
  31.     ' interpret returned information using MIME headers -- not file
  32.     ' extensions.
  33.     
  34.     Response.Buffer = TRUE
  35.     Response.ContentType = "image/gif"
  36.  
  37.  
  38.     ' Create ADO Connection Object.  Use IISSDK OBDC Souce with 
  39.     ' default sa account and no password
  40.  
  41.     Set oConn = Server.CreateObject("ADODB.Connection")
  42.     oConn.Open "IISSDK", "sa", ""
  43.  
  44.  
  45.     ' Query SQL to obtain recordset containing gif BLOB
  46.  
  47.     Set oRs = oConn.Execute("SELECT logo FROM pub_info WHERE pub_id='0736'")
  48.  
  49.  
  50.     ' Obtain local variable of GIF
  51.  
  52.     PicSize = oRs("logo").ActualSize
  53.     Pic = oRs("logo").GetChunk(PicSize)
  54.     
  55.     
  56.     ' Write Data back to client.  Because MIME type is set to
  57.     ' image/gif, the browser will automatically render as picture    
  58.     
  59.     Response.BinaryWrite Pic
  60.     Response.End
  61. %>
  62.