But I have a problem with the dataSource. The number of columns in myDataSet may be different each time. Then it looks as if I have to use a new name for the dataSource. The old still seems to exist, and I get an error about columns which do not match. Is it right, that the name must be unique for each dataSet size?
I came accross exactly the same problem yesterday, so I had to add a random number to the dataSource name each time a new data source is created.
A method to get rid of existing dataSource does not seem to be in place…
Good to hear that I’m not the only one stepping into this
Yes, I also did not find a method to remove/destroy the data source. Actually I expected it to disappear with the form.
The reason we have not added a removeDataSource method is because internally in Servoy we can never be sure that the data source is needed again at some point.
It would give many internal errors if a removed data source was reused because the user goes back to a form unexpected by the developer.
If you are sure the data is not to be used anymore, you can call ds.removeRow(-1), this will delete all data in the dataset from memory, but the structure will remain.
In the case that the columns may differ each time a data source is created, you can either create a unique name each time (for instance, use a counter) or, if the number of possible combinations is limited, generate a name for each possible combination.
Including each column name in the data source name could be an option.