Deleting Fields from Recordset Object

Deleting Fields from Recordset Object

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 ?

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.

See also  How HealthStream Learning Center Supports Healthcare Education and Compliance

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist