home *** CD-ROM | disk | FTP | other *** search
- <% @ LANGUAGE=JScript %>
-
- <!--#include file="adojavas.inc"-->
-
- <%
- // This sample utilizes the Image field in the PUB_INFO table.
- // This table is installed with Microsoft SQL Server in
- // the PUBS database.
-
- // To run this sample, you must first do the following:
- //
- // 1) Go to the System Control Panel
- // 2) Open the OBDC Control Panel
- // 3) Select the System DSN Tab and Add a Source
- // 4) Choose the SQL Server Driver and hit Finish
- // 5) Name Source "IISSDK", enter name of the local server
- // 6) Setup Security (Note: If you have setup a password on the
- // SQL Server, you may have to change the example below)
- // 7) Set Default Database to the pubs db that comes with SQL
-
-
- var oConn;
- var oRs;
- var Pic;
- var PicSize;
-
-
- // Setup HTTP Header Information so that the browser interprets
- // the returned data as a gif graphic file. Note that browsers
- // interpret returned information using MIME headers -- not file
- // extensions.
-
- Response.Buffer = true;
- Response.ContentType = "image/gif";
-
-
- // Create ADO Connection Object. Use IISSDK OBDC Souce with
- // default sa account and no password
-
- oConn = Server.CreateObject("ADODB.Connection");
- oConn.Open("IISSDK", "sa", "");
-
-
- // Query SQL to obtain recordset containing gif BLOB
-
- oRs = oConn.Execute("SELECT logo FROM pub_info WHERE pub_id='0736'");
-
-
- // Obtain local variable of GIF
-
- PicSize = oRs("logo").ActualSize;
- Pic = oRs("logo").GetChunk(PicSize);
-
-
- // Write Data back to client. Because MIME type is set to
- // image/gif, the browser will automatically render as picture
-
- Response.BinaryWrite(Pic);
- Response.End();
- %>
-