housepics.ado.asp
<%@ LANGUAGE = VBScript %>
<% Option Explicit %>
<%
'----------------------------------------------------------------------
' housepics.asp - SpeedGen ASP Sample Script
' (c) 2000-2002 Optimized Software Ltd. All Rights Reserved.
'----------------------------------------------------------------------
' This script demonstrates:
' - Reading ADO RecordSets
' - Excel 5.0/95 Workbook
' - Dynamic Picture Insertion (Picture Field Markers)
' (pulling JPEGs from an access database)
'
' Notes:
' - Do NOT write any HTML or use Response.Write!
' - Dynamic Picture Insertion (Picture Field Markers) are currently
' only available when using Excel 5.0/95 Source Workbooks (Templates).
' Excel SpeedGen v2.1 will support greatly enhanced Dynamic Picture
' Insertion.
' - Server Side (or no) Cursors can cause queries (and stored procedures) to
' be executed multiple times! Using a Client Side Cursor will prevent this.
'----------------------------------------------------------------------
' Tip: Code Library at http://www.excelspeedgen.com/code
'----------------------------------------------------------------------
Dim dbFile ' Database File
Dim oConn ' ADO Connection object
Dim Rs1 ' Record Source 1
Dim XLS ' SpeedGen Object
Dim SrcBook ' Source Workbook
' Open Microsoft Access Database
dbFile = Server.MapPath("sample.mdb")
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbFile
' Open the RecordSets
Set Rs1 = oConn.Execute("homes") ' SQL Statement (or Table name)
' Create Excel File
Set XLS = Server.CreateObject("XLSpeedGen.ASP")
XLS.EstimatedSize = 350000 ' Set Estimated Output File Size (Critical for speed)
XLS.PictureFilePrefix = Server.MapPath(".") & "\" ' Pictures are in same folder as housepics.asp
' Add RecordSources
XLS.AddRS_ADO Rs1, 20 ' RecordSource 1 (read 20 rows at a time)
SrcBook = Server.MapPath("housepics.xls") ' Location of Source Workbook
XLS.Generate SrcBook, "", True ' Generate SpreadSheet and Stream to Client, Open in Place
Set XLS = Nothing ' Destroy object when done
' Cleanup Code
oConn.close ' Close Connection and all Recordsets
Set oConn = Nothing
%>
This Code Sample is intended for use with Excel SpeedGen