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.