Handle Advanced Arrays With RDS

Often you need a data structure similar to a two-dimensioned array or collection, but you need to manipulate it. For example, you need to sort on certain columns, filter certain rows, or find certain values. These functionalities are already available in the ADO Recordset object. The Microsoft Remote Data Services provides a way to store nondatabase data in a recordset using the DataFactory object. This class can help you create in-memory recordsets. Set the reference to Microsoft Remote Data Services Server 2.1 Library:

 ' code forRInMemoryRSOption ExplicitPrivate df As New RDSServer.DataFactoryPrivate vColInfo()Private nTotalCols As LongPublic Function Create() As ADODB.Recordset	If nTotalCols > 0 Then		Set Create = df.CreateRecordSet(vColInfo)	End IfEnd FunctionPublic Sub Clear()	ReDim vColInfo(0)	nTotalCols = 0End SubPublic Sub AddColumn(szName As String, _	nColType As ADODB.DataTypeEnum, Optional _	nColSize As Long = -1, Optional bNullable _	As Boolean = True)	Dim vCol(3)	ReDim Preserve vColInfo(nTotalCols)	vCol(0) = szName	vCol(1) = CInt(nColType)	vCol(2) = CInt(nColSize)	vCol(3) = bNullable	vColInfo(nTotalCols) = vCol	nTotalCols = nTotalCols + 1End SubPrivate Sub Class_Initialize()	nTotalCols = 0End Sub

Use code like this:

 Dim rsMem As ADODB.RecordsetDim RMemRS As new RInMemoryRS' Create Two Column TableRMemRS.AddColumn "Name", adChar, 10, FalseRMemRS.AddColumn "Age", adchar, 10Set rsMem=RMemRS.Create' Now, you can add the data to the "Memory ' Recordset" for examplersMem.AddNew rsMem!Name = "John"rsMem!Age = 15rsMem.UpdatersMem.AddNew rsMem!Name = "Kevin"rsMem!Age = 25rsMem.Update

You can manipulate rsMem like this:

 rsMem.Filter = "Age > 15"rsMem.Sort = "Age ASC"rsMem.Save szFileNamersMem.Find "Name = 'John'"
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may

man on floor with data

DevX Quick Guide to Data Ingestion

One of the biggest trends of the 21st century is the massive surge in internet usage. With major innovations such as smart technology, social media, and online shopping sites, the internet has become an essential part of everyday life for a large portion of the population. Due to this internet

payment via phone

7 Ways Technology Has Changed Traditional Payments

In today’s digital world, technology has changed how we make payments. From contactless cards to mobile wallets, it’s now easier to pay for goods and services without carrying cash or using a checkbook. This article will look at seven of the most significant ways technology has transformed traditional payment methods.