Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Enterprise
Expertise: All
Oct 14, 1999

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 record
End 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.MoveFirst
End If
Deepak Pant
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date