473,386 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,386 developers and data experts.

The Supports Method of an ADO Recordset Object

ADezii
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
  7.  
  8. If rst.Supports(adApproxPosition) Then
  9.   Debug.Print "Supports AbsolutePosition"
  10. Else
  11.   Debug.Print "Doesn't support AbsolutePosition"
  12. End If
  13.  
  14. If rst.Supports(adBookmark) Then
  15.   Debug.Print "Supports Bookmarks"
  16. Else
  17.   Debug.Print "Doesn't support Bookmarks"
  18. End If
  19.  
  20. If rst.Supports(adDelete) Then
  21.   Debug.Print "Supports Delete"
  22. Else
  23.   Debug.Print "Doesn't support Delete"
  24. End If
  25.  
  26. If rst.Supports(adFind) Then
  27.   Debug.Print "Supports Find"
  28. Else
  29.   Debug.Print "Doesn't support Find"
  30. End If
  31.  
  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
  37.  
  38. If rst.Supports(adIndex) Then
  39.   Debug.Print "Supports Index"
  40. Else
  41.   Debug.Print "Doesn't support Index"
  42. End If
  43.  
  44. If rst.Supports(adMovePrevious) Then
  45.   Debug.Print "Supports MovePrevious"
  46. Else
  47.   Debug.Print "Doesn't support MovePrevious"
  48. End If
  49.  
  50. If rst.Supports(adResync) Then
  51.   Debug.Print "Supports Resync"
  52. Else
  53.   Debug.Print "Doesn't support Resync"
  54. End If
  55.  
  56. If rst.Supports(adSeek) Then
  57.   Debug.Print "Supports Seek"
  58. Else
  59.   Debug.Print "Doesn't support Seek"
  60. End If
  61.  
  62. If rst.Supports(adUpdate) Then
  63.   Debug.Print "Supports Update"
  64. Else
  65.   Debug.Print "Doesn't support Update"
  66. End If
  67.  
  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
  3.  
  4. Set rstSupports1 = New ADODB.Recordset
  5.  
  6. strSQL = "Select * From Employees;"
  7.  
  8. With rstSupports1
  9.   .Source = strSQL
  10.   .ActiveConnection = CurrentProject.Connection
  11.   .CursorType = adOpenForwardOnly
  12.   .LockType = adLockReadOnly
  13. End With
  14.  
  15. rstSupports1.Open , , , , adCmdText
  16.  
  17. Debug.Print "-----------------------------------------------------------------------------------"
  18. Debug.Print "SQL Statement Source | Forward Only Cursor | Read Only Recordset | acCmdText Option"
  19. Debug.Print "-----------------------------------------------------------------------------------"
  20.  
  21. Call RecordsetSupport(rstSupports1)
  22.  
  23. rstSupports1.Close
  24. Set rstSupports1 = Nothing
Expand|Select|Wrap|Line Numbers
  1. 'Recordset #2 (Open)
  2. On Error GoTo Err_Command115_Click
  3.  
  4. Dim rstSupports2 As ADODB.Recordset
  5.  
  6. Set rstSupports2 = New ADODB.Recordset
  7.  
  8. With rstSupports2
  9.   .Source = "Employees"
  10.   .ActiveConnection = CurrentProject.Connection
  11.   .CursorType = adOpenKeyset
  12.   .LockType = adLockOptimistic
  13. End With
  14.  
  15. rstSupports2.Open , , , , adCmdTableDirect
  16.  
  17. Debug.Print "-----------------------------------------------------------------------------------"
  18. Debug.Print "Table Type Recordset | Keyset Cursor | Optimistic Locking | acCmdTableDirect Option"
  19. Debug.Print "-----------------------------------------------------------------------------------"
  20.  
  21. Call RecordsetSupport(rstSupports2)
  22.  
  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 8942

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

Similar topics

5
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...
4
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...
5
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...
5
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...
12
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...
1
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...
7
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;"...
0
ADezii
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,...
7
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...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.