debt.ado.asp
<%@ LANGUAGE = VBScript %>
<% Option Explicit %>
<%
'----------------------------------------------------------------------
' debt.asp - SpeedGen ASP Sample Script
' (c) 2000-2002 Optimized Software Ltd. All Rights Reserved.
'----------------------------------------------------------------------
' This script demonstrates:
' - Reading ADO RecordSets
' - Multiple RecordSet Queries
' - The >>$Now Standard Field Marker
' - Sum (Total) of a Field in a RecordSet. This can be applied to any formula.
'
' Notes:
' - Do NOT write any HTML or use Response.Write!
' - 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 Rs2 ' Record Source 2
Dim Rs3 ' Record Source 3
Dim Rs4 ' Record Source 4
Dim Rs5 ' Record Source 5
Dim Rs6 ' Record Source 6
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("SELECT * From debt WHERE CreditType = 'Bank Credit Cards';") ' SQL Statement (or Table name)
Set Rs2 = oConn.Execute("SELECT * From debt WHERE CreditType = 'Department Store Cards';") ' SQL Statement (or Table name)
Set Rs3 = oConn.Execute("SELECT * From debt WHERE CreditType = 'Automobile Loans';") ' SQL Statement (or Table name)
Set Rs4 = oConn.Execute("SELECT * From debt WHERE CreditType = 'Other Loans';") ' SQL Statement (or Table name)
Set Rs5 = oConn.Execute("SELECT * From debt WHERE CreditType = 'Other';") ' SQL Statement (or Table name)
Set Rs6 = oConn.Execute("debt") ' SQL Statement (or Table name)
' Create Excel File
Set XLS = Server.CreateObject("XLSpeedGen.ASP")
XLS.EstimatedSize = 50000 ' Set Estimated Output File Size (Critical for speed)
' Add Variables
XLS.AddVariable "CustomerName", "Dave Singleton" ' for >>$CustomerName Field Marker
' Add RecordSources
XLS.AddRS_ADO Rs1, 20 ' RecordSource 1 (read 20 rows at a time)
XLS.AddRS_ADO Rs2, 20 ' RecordSource 2 (read 20 rows at a time)
XLS.AddRS_ADO Rs3, 20 ' RecordSource 3 (read 20 rows at a time)
XLS.AddRS_ADO Rs4, 20 ' RecordSource 4 (read 20 rows at a time)
XLS.AddRS_ADO Rs5, 20 ' RecordSource 5 (read 20 rows at a time)
XLS.AddRS_ADO Rs6, 20 ' RecordSource 6 (read 20 rows at a time)
SrcBook = Server.MapPath("debt.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