Destroying a datasource

Hi All

I am currently basing some dynamic forms on a datasource created from a dataset

using

var query = 'select distinct '+field+' from '+table +' order by ' +field+' asc';
dataset = databaseManager.getDataSetByQuery(globals.vServerToUse, query, null, 999);
uri = dataset.createDataSource('mydata2', [DM_COLUMNTYPE.TEXT]);

which is working fine

However I need to be able to destroy the datasources once I am done with them, What is the best way to acheive this.

Regards

Zuke

dataset = null
uri = null

Will this actually destroy them, so I can re use the data source name again?

As i am gettin gthe following error

Borrow prepareStatement from pool failed
 > com.servoy.j2db.dataprocessing.DataException: Borrow prepareStatement from pool failed

Regards

It seems using a UUID for the data source name and using your suggestion has solved the issue

Many Thanks

Zuke,

You cannot really destroy a data source, it will be destroyed automatically when the client disconnects.

Using a different name each time is an option.
If you choose this, it is best to delete all data from the data source by calling dataset.removeRow(-1) when done with the data set.

You can also reuse a data source multiple times, but only if the columns in the set are the same.
When you reuse an existing data source, the data from previous use is deleted (if it was not already) and the data source is filled with the new data.

The error you received probably happened when the second use of the data source had different columns than the first one.
From the log file (servoy_log.txt) you should see a more detailed error.

Rob