home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 9 / IOPROG_9.ISO / contrib / iis4 / iis4_07.cab / Blob_JScript.asp < prev    next >
Encoding:
Text File  |  1997-09-04  |  1.7 KB  |  61 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.     // To run this sample, you must first do the following:
  11.     //
  12.     //            1) Go to the System Control Panel
  13.     //            2) Open the OBDC Control Panel 
  14.     //            3) Select the System DSN Tab and Add a Source
  15.     //            4) Choose the SQL Server Driver and hit Finish
  16.     //            5) Name Source "IISSDK", enter name of the local server
  17.     //            6) Setup Security (Note: If you have setup a password on the
  18.     //               SQL Server, you may have to change the example below)
  19.     //            7) Set Default Database to the pubs db that comes with SQL
  20.  
  21.  
  22.     var oConn;    
  23.     var oRs;        
  24.     var Pic;        
  25.     var PicSize;
  26.  
  27.  
  28.     // Setup HTTP Header Information so that the browser interprets
  29.     // the returned data as a gif graphic file.  Note that browsers
  30.     // interpret returned information using MIME headers -- not file
  31.     // extensions.
  32.     
  33.     Response.Buffer = true;
  34.     Response.ContentType = "image/gif";
  35.  
  36.  
  37.     // Create ADO Connection Object.  Use IISSDK OBDC Souce with 
  38.     // default sa account and no password
  39.  
  40.     oConn = Server.CreateObject("ADODB.Connection");
  41.     oConn.Open("IISSDK", "sa", "");
  42.  
  43.  
  44.     // Query SQL to obtain recordset containing gif BLOB
  45.  
  46.     oRs = oConn.Execute("SELECT logo FROM pub_info WHERE pub_id='0736'");
  47.  
  48.  
  49.     // Obtain local variable of GIF
  50.  
  51.     PicSize = oRs("logo").ActualSize;
  52.     Pic = oRs("logo").GetChunk(PicSize);
  53.     
  54.     
  55.     // Write Data back to client.  Because MIME type is set to
  56.     // image/gif, the browser will automatically render as picture    
  57.     
  58.     Response.BinaryWrite(Pic);
  59.     Response.End();
  60. %>
  61.