NCS Logo - Click for home page Northstar Developer Center
Platforms
All Platforms
.NET Framework (1.x - 4.x)
Active Server Pages
ASP.NET
C#
SQL Server
VB.NET
Visual Basic

Keywords
.NET Data Types
.NET E-mail
.NET Events
.NET Functions
.NET Object Programming
.NET System.Configuration
.NET System.Diagnostics
.NET System.IO
.NET System.Net
.NET System.Net.Sockets
Active Data Objects
ASP Architecture
ASP Black Belt
ASP Built-in Functions
ASP Built-in Objects
ASP Debugging
ASP Performance
ASP Security
ASP Syntax
ASP.NET Authentication
ASP.NET Controls
ASP.NET Data Access
ASP.NET Features
ASP.NET Master Pages
ASP.NET Page Events
ASP.NET Security
ASP.NET ViewState
Atom
Certifications
COM, DCOM, COM+
Data Access
E-Mail
Errors
Exporting Data
HTML Tips
IIS
Object-Oriented Programming
RSS
SQL
Uncategorized ASP Tips
VB API Programming
VB Forms
VB Syntax
XML

Book Support
Visual Basic 6 Bible
ASP Bible
ASP Weekend Crash Course
ASP.NET At Work
Creating Web Services

Saving a Recordset

Written by Eric Smith, Northstar Computer Systems LLC

One of the features of the ADO Recordset in ADO 2.5 is the ability to save the recordset to a disk file. There are currently two file formats that you can use. The first, and default, is called the Advanced Table DataGram Format. This file format will allow you to reload the recordset by specifying its filename as the source when you open your recordset. Here's the code for saving the recordset:
Dim dcnDB 			' As ADODB.Connection
Dim rsData 			' As ADODB.Recordset

Set dcnDB = Server.CreateObject("ADODB.Connection")
dcnDB.ConnectionString = _
   "Provider=SQLOLEDB;" _
	& "Data Source=Server;" _
	& "Initial Catalog=DB;" _
	& "User ID=user;" _
	& "Password=password;"
dcnDB.Open
Set rsData = dcnDB.Execute("SELECT * FROM Customers")
rsData.Save "C:\DataFile.txt"
rsData.Close
dcnDB.Close
To reopen this file, you do the reverse:
Dim rsData		' As ADODB.Recordset
Set rsData = Server.CreateObject("ADODB.Recordset")
rsData.Open "C:\DataFile.txt"
Do Until rsData.EOF
	Response.Write rsData("CompanyName") & "
" rsData.MoveNext Loop rsData.Close
If you have a need to save searches, this is a fairly straightforward to do it. You save the results to a file and then you can reload them later.

Keywords: [ Uncategorized ASP Tips ]

Publication Date: 7/1/2000