Should dataSource name be unique?

Hi

According to a user configuration, I create a dynamic form with

solutionModel.newForm()

The dataset I use is “hand made” with

var myDataSet = databaseManager.createEmptyDataSet();
// I fill it
var myDataSource = myDataSet.createDataSource(dataSourceName,...);

I use myDataSource when I create the form.

During application runtime a user may create the dynamic form several times. I managed to destroy it before recreating it with

history.removeForm(formName);
solutionModel.removeForm(formName);

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?

Thanks for help and regards

You can add a case about this in our support system, it seems if same name will keep the old structure (columns), then inserting the data will fail.

Thank you for the answer. I did file a case.

Regards

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.

Regards

Birgit,

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.

Rob