0

I have a Recordset which has 1 column/field of data/records.

It has up to about hundreads or thousands of string values depending on the date range picked.

I then clone that data into a Stream (as explained in an answer to another question) to keep it and reuse the Recordset. That Stream can be turned back into a new Recordset if needed or (probably) an array of some sort.

Later in the code I need to check if some values are in that Stream/Recordset/Array/etc.

Other than turning the Stream back into a Recordset and use a normal loop with Recordset.Move methods (example) to check if each of those values are or not in the stored data, is there any other more efficient way to check it?

user7393973
  • 2,270
  • 1
  • 20
  • 58
  • 1
    If you want to persist a recordset you can use a client-side cursor and disconnect it. If you need to save it to a file you can use the `Save` method: https://learn.microsoft.com/en-us/sql/ado/guide/data/persisting-data?view=sql-server-2017 If you need to check for specific values you can use the `Find` method: https://learn.microsoft.com/en-us/sql/ado/reference/ado-api/find-method-ado?view=sql-server-2017 – Tim Williams Jul 10 '19 at 17:08
  • The `Find` method is what I was looking for. Thanks @TimWilliams. – user7393973 Jul 12 '19 at 13:02

1 Answers1

3

From Microsofts documentation:

Use the BOF and EOF properties to determine whether a Recordset object contains records or whether you have gone beyond the limits of a Recordset object when you move from record to record.

The BOF property returns True (-1) if the current record position is before the first record and False (0) if the current record position is on or after the first record.

The EOF property returns True if the current record position is after the last record and False if the current record position is on or before the last record.

If either the BOF or EOF property is True, there is no current record.


So you could check to see if either of these properties are true, then you would know there is no current record.

Or you could do the opposite, and check to see if neither are true. Example:

If Not Rs.BOF And Not Rs.EOF Then
    ' Do something with your recordset
End If
Robert Todar
  • 2,085
  • 2
  • 11
  • 31