472,789 Members | 862 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 472,789 developers and data experts.

The Supports Method of an ADO Recordset Object

8,834 Expert 8TB
When you create an ADO Recordset, you should have some idea as to what functionality the Recordset does/does not provide. Some critical questions may, and should, be:
  1. Can I add New Records to the Recordset?
  2. Does the Recordset support Bookmarks?
  3. Can we use the Find and/or Seek Methods with this Recordset?
  4. Does the Recordset support the use of Indexes?
  5. Will the Absoluteposition property be able to be used on this Recordset?
  6. etc....

Fortunately, all these questions and more can be easily answered by using the Supports Method of an ADO Recordset Object. This Method determines what kind of functionality an ADO Recordset Object supports. It returns a Boolean (True/False) value that indicates whether all the features identified by its single Argument are supported by the Provider. If a specific functionality is supported, it returns True, otherwise False.

To demonstrate the use of this Method, I will:
  1. Display a 'Wrapper' Function Sub-Routine called RecordsetSupport() that accepts a single Argument (an ADO Recordset Object).
  2. Create 2 very different ADO Recordsets.
  3. Pass the Recordset Objects to the RecordsetSupport() Sub-Routine.
  4. Display the Output for each Recordset indicating what functionality each supports.
  5. The preceding steps will be performed for each Recordset in turn.
Expand|Select|Wrap|Line Numbers
  1. Public Sub RecordsetSupport(rst As ADODB.Recordset)
  2. If rst.Supports(adAddNew) Then
  3.   Debug.Print "Supports AddNew"
  4. Else
  5.   Debug.Print "Doesn't support AddNew"
  6. End If
  8. If rst.Supports(adApproxPosition) Then
  9.   Debug.Print "Supports AbsolutePosition"
  10. Else
  11.   Debug.Print "Doesn't support AbsolutePosition"
  12. End If
  14. If rst.Supports(adBookmark) Then
  15.   Debug.Print "Supports Bookmarks"
  16. Else
  17.   Debug.Print "Doesn't support Bookmarks"
  18. End If
  20. If rst.Supports(adDelete) Then
  21.   Debug.Print "Supports Delete"
  22. Else
  23.   Debug.Print "Doesn't support Delete"
  24. End If
  26. If rst.Supports(adFind) Then
  27.   Debug.Print "Supports Find"
  28. Else
  29.   Debug.Print "Doesn't support Find"
  30. End If
  32. If rst.Supports(adHoldRecords) Then
  33.   Debug.Print "Supports Move without Save"
  34. Else
  35.   Debug.Print "Doesn't support Move without Save"
  36. End If
  38. If rst.Supports(adIndex) Then
  39.   Debug.Print "Supports Index"
  40. Else
  41.   Debug.Print "Doesn't support Index"
  42. End If
  44. If rst.Supports(adMovePrevious) Then
  45.   Debug.Print "Supports MovePrevious"
  46. Else
  47.   Debug.Print "Doesn't support MovePrevious"
  48. End If
  50. If rst.Supports(adResync) Then
  51.   Debug.Print "Supports Resync"
  52. Else
  53.   Debug.Print "Doesn't support Resync"
  54. End If
  56. If rst.Supports(adSeek) Then
  57.   Debug.Print "Supports Seek"
  58. Else
  59.   Debug.Print "Doesn't support Seek"
  60. End If
  62. If rst.Supports(adUpdate) Then
  63.   Debug.Print "Supports Update"
  64. Else
  65.   Debug.Print "Doesn't support Update"
  66. End If
  68. If rst.Supports(adUpdateBatch) Then
  69.   Debug.Print "Supports UpdateBatch"
  70. Else
  71.   Debug.Print "Doesn't support UpdateBatch"
  72. End If
  73. End Sub
Expand|Select|Wrap|Line Numbers
  1. 'Recordset #1 (Restrictive)
  2. Dim rstSupports1 As ADODB.Recordset, strSQL As String
  4. Set rstSupports1 = New ADODB.Recordset
  6. strSQL = "Select * From Employees;"
  8. With rstSupports1
  9.   .Source = strSQL
  10.   .ActiveConnection = CurrentProject.Connection
  11.   .CursorType = adOpenForwardOnly
  12.   .LockType = adLockReadOnly
  13. End With
  15. rstSupports1.Open , , , , adCmdText
  17. Debug.Print "-----------------------------------------------------------------------------------"
  18. Debug.Print "SQL Statement Source | Forward Only Cursor | Read Only Recordset | acCmdText Option"
  19. Debug.Print "-----------------------------------------------------------------------------------"
  21. Call RecordsetSupport(rstSupports1)
  23. rstSupports1.Close
  24. Set rstSupports1 = Nothing
Expand|Select|Wrap|Line Numbers
  1. 'Recordset #2 (Open)
  2. On Error GoTo Err_Command115_Click
  4. Dim rstSupports2 As ADODB.Recordset
  6. Set rstSupports2 = New ADODB.Recordset
  8. With rstSupports2
  9.   .Source = "Employees"
  10.   .ActiveConnection = CurrentProject.Connection
  11.   .CursorType = adOpenKeyset
  12.   .LockType = adLockOptimistic
  13. End With
  15. rstSupports2.Open , , , , adCmdTableDirect
  17. Debug.Print "-----------------------------------------------------------------------------------"
  18. Debug.Print "Table Type Recordset | Keyset Cursor | Optimistic Locking | acCmdTableDirect Option"
  19. Debug.Print "-----------------------------------------------------------------------------------"
  21. Call RecordsetSupport(rstSupports2)
  23. rstSupports2.Close
  24. Set rstSupports2 = Nothing
OUTPUT from Recordset #1
Expand|Select|Wrap|Line Numbers
  1. -----------------------------------------------------------------------------------
  2. SQL Statement Source | Forward Only Cursor | Read Only Recordset | acCmdText Option
  3. -----------------------------------------------------------------------------------
  4. Doesn't support AddNew
  5. Doesn't support AbsolutePosition
  6. Doesn't support Bookmarks
  7. Doesn't support Delete
  8. Supports Find
  9. Doesn't support Move without Save
  10. Doesn't support Index
  11. Doesn't support MovePrevious
  12. Supports Resync
  13. Doesn't support Seek
  14. Doesn't support Update
  15. Doesn't support UpdateBatch
OUTPUT from Recordset #2
Expand|Select|Wrap|Line Numbers
  1. -----------------------------------------------------------------------------------
  2. Table Type Recordset | Keyset Cursor | Optimistic Locking | acCmdTableDirect Option
  3. -----------------------------------------------------------------------------------
  4. Supports AddNew
  5. Doesn't support AbsolutePosition
  6. Supports Bookmarks
  7. Supports Delete
  8. Supports Find
  9. Supports Move without Save
  10. Supports Index
  11. Supports MovePrevious
  12. Doesn't support Resync
  13. Supports Seek
  14. Supports Update
  15. Supports UpdateBatch
Oct 15 '07 #1
0 8807

Sign in to post your reply or Sign up for a free account.

Similar topics

by: shank | last post by:
Can anyone give me some general ideas on why an error like Object doesn't support this property or method: 'ZoneRS.MoveFirst' comes up on a page? MoveFirst is a command to move to the first...
by: Thomas Scheiderich | last post by:
Why would you use the Recordset object over the Execute method of getting data from your Sql database. For example, I have the following: Execute Method...
by: j.mandala | last post by:
Someone is trying to run my Access 2002 database under Access 2003. He has had a number of problems: 1) i used the MSComCt2.ocx for it's Date and Time picker. I can't find it under 2003. Do I...
by: Sunnyrain | last post by:
I am developing a program in Access 2000. I couldn't make OpenRecordset method work right. It's working when I opened a simple SQL query below in OpenRecordset. ..... Dim dbs As Database, rst...
by: Cy | last post by:
Hello Fellow New Group Folks, Here's today's problem. I was called in to help convert an Access 97 database to Access 2000. 99% of all my Access Dev. work has occurred in 2000, so I know very...
by: sphinney | last post by:
All, I have a ADODB.Recordset in my Access 2002 project. I've been able to successfully add fields to the record set. According the the MS Access help files, I now must update the recordset to...
by: Bryan | last post by:
Hi , I am using ADO (ADODB) with access database. Not sure what I am doing wrong.here. Can anyone please help me? string mdbFile = System.IO.Directory.GetCurrentDirectory() +" \\bTrack.mdb;"...
by: ADezii | last post by:
In last week's Tip, I showed you how to use the ISAMStats Method of the DBEngine (DAO) to return vital statistics concerning Query executions such as: Disk Reads and Writes, Cache Reads and Writes,...
by: mirandacascade | last post by:
The questions are toward the bottom of this post. Situation is this: 1) Access 97 2) Multi-user appplication 3) SQL Server 2000 4) Sporadically (i.e. less than 1% of the time) encounter the...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
by: lllomh | last post by:
How does React native implement an English player?
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.