home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_07.cab / Blob_JScript.asp < prev    next >
Text File  |  1997-10-25  |  1KB  |  50 lines

  1. <% @ LANGUAGE=JScript    %>
  2.  
  3. <!--#include file="adojavas.inc"-->
  4.  
  5. <%
  6.     // This sample utilizes the Image field in the PUB_INFO table.  
  7.     // This table is installed with Microsoft SQL Server in
  8.     // the PUBS database.
  9.     
  10.  
  11.     var oConn;    
  12.     var oRs;        
  13.     var Pic;        
  14.     var PicSize;
  15.  
  16.  
  17.     // Setup HTTP Header Information so that the browser interprets
  18.     // the returned data as a gif graphic file.  Note that browsers
  19.     // interpret returned information using MIME headers -- not file
  20.     // extensions.
  21.     
  22.     Response.Buffer = true;
  23.     Response.ContentType = "image/gif";
  24.  
  25.  
  26.     // Create ADO Connection Object.  Use IISSDK OBDC Souce with 
  27.     // default sa account and no password
  28.  
  29.     oConn = Server.CreateObject("ADODB.Connection");
  30.     oConn.Open("DSN=LocalServer;UID=sa;PWD=;DATABASE=pubs");
  31.  
  32.  
  33.     // Query SQL to obtain recordset containing gif BLOB
  34.  
  35.     oRs = oConn.Execute("SELECT logo FROM pub_info WHERE pub_id='0736'");
  36.  
  37.  
  38.     // Obtain local variable of GIF
  39.  
  40.     PicSize = oRs("logo").ActualSize;
  41.     Pic = oRs("logo").GetChunk(PicSize);
  42.     
  43.     
  44.     // Write Data back to client.  Because MIME type is set to
  45.     // image/gif, the browser will automatically render as picture    
  46.     
  47.     Response.BinaryWrite(Pic);
  48.     Response.End();
  49. %>
  50.