RecordSet.removeAll( )

RecordSet.removeAll( ) MethodFlash 6

deletes all records in a recordset
myRecordSet.removeAll( )


The removeAll( ) method removes the entire contents of the RecordSet object. The structure (column names) of the RecordSet object remains intact, however, and the internal identifiers in use before calling the removeAll( ) method are not reused.


The following code removes the contents of the RecordSet object:

#include ""
var myRecordset_rs = new RecordSet(["First", "Last", "Email"]);
myRecordset_rs.addItem({First:"Tom", Last:"Muck", Email:""});
myRecordset_rs.addItem({First:"Jack", Last:"Splat", Email:""});
myRecordset_rs.removeAll( );
trace(myRecordset_rs.getLength( ));
trace(myRecordset_rs.getColumnNames( ));

In this case, the Output window shows that the recordset has a length of 0, but it also shows that the field names are still in place. If we add a record to the RecordSet object now, the internal identifier of the row will be incremented from where it left off before; the internal identifier numbers of the two rows that existed previously are not reused:

myRecordset_rs.addItem({First:"Jack", Last:"Splat", Email:""});

The Output window should show "2".

To completely delete the RecordSet object rather than simply empty the contents, you can set it to null:

myRecordset_rs = null;

See Also

RecordSet.getItemId( ), RecordSet.removeItemAt( )

    Part III: Advanced Flash Remoting