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: Visual Basic
Expertise: Beginner
May 11, 2000

Deleting Fields from Recordset Object

Question:
I am using a disconnected recordset (adOpenStatic, adUseClient) which is obtained by executing a stored procedure using command an object. I tried to delete some fields from the recodset using rst.Fields.Delete "FieldName" syntax, only to get error saying this operation cannot be performed in this context. Any ideas why this might happen and how to make it work? I need to remove some fields from recordset at runtime as per user preferences.

Also I tried to append an existing Field object from a recordset to a new recordset ( created using set rst = new ADODB.Recordset) but failed. I think I was wrong on this one. Is there a way to take a few fields from existing recordset and copy them directly (with all data) over to another recordset ?

Answer:
You can only add and remove fields from a recordset while it is closed. To clone a recordset with only some of the fields you will have to instantiate a new recordset, append the desired fields, and then loop throught the source recordset and copy over the values.

DevX Pro
 
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