File I/O - Use a data table ?
-
I am a newbie, be gentle. I am starting out with basic File I/O and have seen an example here on 'The Code Project' (TextFileImporter) that uses a data table classto hold the data and then display it in a grid via a dataset. I want to temporarily store the data whilst parsing each line and validating but ultimately don't want to display the data in a grid. Is it common practice to still use a data table in VB.NET or should i use an array or string as in the VB6 style. Thanks Barney
-
I am a newbie, be gentle. I am starting out with basic File I/O and have seen an example here on 'The Code Project' (TextFileImporter) that uses a data table classto hold the data and then display it in a grid via a dataset. I want to temporarily store the data whilst parsing each line and validating but ultimately don't want to display the data in a grid. Is it common practice to still use a data table in VB.NET or should i use an array or string as in the VB6 style. Thanks Barney
Good question. There are different answers depending on what you want. If you want ease of programming then a datatable is a good choice. This is because it uses rows and columns with which you are probably familiar. If you want speed of processing then I would recommend an arraylist. Arraylists are faster to read and write to, in my experience, than arrays. The catch is that arraylists are not multidimensional. The good news is that there is a way around this problem i.e. how to represent rows and colums in an arraylist. I use arraylists in a csv class I created and they whack the pants off arrays when it comes to processing speed. Alternatively you could use a dataview. What this does is basically make a view of your table. So that it contains the same data. The advantage of a dataview is that you can very easily apply sorts and filters. Also with a dataview all you basically do is point the dataview object to your table et voila you have another way of looking at your datatable. I hope this is of some help to you.:)
You always pass failure on the way to success.
-
Good question. There are different answers depending on what you want. If you want ease of programming then a datatable is a good choice. This is because it uses rows and columns with which you are probably familiar. If you want speed of processing then I would recommend an arraylist. Arraylists are faster to read and write to, in my experience, than arrays. The catch is that arraylists are not multidimensional. The good news is that there is a way around this problem i.e. how to represent rows and colums in an arraylist. I use arraylists in a csv class I created and they whack the pants off arrays when it comes to processing speed. Alternatively you could use a dataview. What this does is basically make a view of your table. So that it contains the same data. The advantage of a dataview is that you can very easily apply sorts and filters. Also with a dataview all you basically do is point the dataview object to your table et voila you have another way of looking at your datatable. I hope this is of some help to you.:)
You always pass failure on the way to success.
Thanks, i think i'll opt for the data table for now then, just to get up and running as i'm only dealing with reasonably small files. For larger files though i'll consider arraylist. Many Thanks:-D