System.dataset.addrow change Date datatype to Unicode

“A picture is worth a thousand words” (especially if you do not know the language well)

Regards,

The problem here seems to lie in the creating of an empty dataset with the toDataSet function and not in the addRow function. When you create a dataset with 3 columns but zero rows, every one of the columns is then defined as a string type. When you first append the data and then convert it to a dataset the function sees what types of values are in each column and then defines the dataset accordingly.

I can check on it, but I’m not sure there is much that can be done in this situation. When a dataset is created it’s columns need to have defined types.

Is there a reason you can’t pass your data in when you call the toDataSet function? If you appended at least one row of data before calling the toDataSet function then the column types would be set appropriately and when you called the addRow function after that everything would work as expected. You could even seed the dataset with a dummy row of data with the correct types and then call the deleteRow function.

A word of warning when using the setValue, addRow, deleteRow, and updateRow functions: These functions are very inefficient because the dataset is essentially copied and then recreated. Datasets are immutable and therefore cannot be modified after they are created, hence all the copying and recreating that needs to be done. If you need to do something multiple times and have all your row data before the dataset is created then it’s going to be far more efficient to loop through adding all your row data to a list, and then calling the toDataSet function with your list of rows.

Considering that here are an example doing the same way that you say, it’s ok for me.

This post can serve to warn in case anyone tries this and do not get the expected result.

Thanks

Hello guys,

I’m having exactly the same problem. I need to add a row in a dataset but I need to specify that the datatype of the dataset will be a “date” information. Can you please share the solution for this topic?

Use DatasetBuilder, this post may help you out,

2 Likes