Use Recordset.Supports() Method for Robust Code

You can use Supports() method of ADODB.Recordset object to write robust code. This method takes in a enum parameter and returns a boolean value which can be used to determine whether a specified Recordset object supports particular functionality.

The enum constants that can be passed to this method to check if recordset supports a particular functionality are adAddNew, adApproxPosition, adBookmark, adDelete, adFind, adHoldRecords, adMovePrevious, adNotify, adResync, adUpdate, and adUpdateBatch.

For example:
(a)You can use AddNew() method only when the recordset supports addition of new records. This can be easily checked using the Supports method:

 If (oRecordset.Supports(adAddNew)) Then' recordset supports addition of new recordEnd If

(b)Another example would be in case of forward-only recordsets where backward movement may generate an error or decrease the performance of your application. Normally you should receive an error if you call MoveFirst() on forward-only recordsets but some providers may allow this, and implement it by resubmitting the command. For example, the OLEDB driver for ODBC allows MoveFirst() when talking to SQL Server, even though the Supports(adMovePrevious) method returns False. In all such cases you should use Supports(adMovePrevious) otherwise it can degrade the performance if the command that has been resubmitted takes a lot of time.

 If (oRecordset.Supports(adMovePrevious)) Then    ' recordset allows backward movement so move to the first record    oRecordset.MoveFirstEnd If
Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS

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