Use Recordset.Supports() Method for Robust Code

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:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes