By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,672 Members | 1,628 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,672 IT Pros & Developers. It's quick & easy.

DataTable or ArrayList

P: n/a
I'm trying to determine which type of collection to use, DataTable or
ArrayList. I understand that an ArrayList can be linked to databound
objects if it contains the IList interface.

Is there a recommendation to use one over the other. If you are not going
to bind the collection to any objects should an ArrayList be used? Is there
a benefit on size? If I have a 200,000 rows of data, should a DataTable be
used in this case?

Any information or experiences would be greatful.

-StinkyDuck
Nov 3 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
I'm sure others will have different opinions, but my preference is to:

Use ArrayList for collections that are not data bound and which are
not used to update a database.

Use BindingList(Of T) for collections that are data bound. BindingList
doesn't do sorting or searching by default, but it is not difficult to
subclass it to add those features.

Use DataSet / DataTable for collections that are fetched from a
database, modified, and then used to update the database. I wouldn't
use DataSet / DataTable for large amounts of data.

On Fri, 2 Nov 2007 22:04:51 -0500, "StinkyDuck" <st********@gmail.com>
wrote:
>I'm trying to determine which type of collection to use, DataTable or
ArrayList. I understand that an ArrayList can be linked to databound
objects if it contains the IList interface.

Is there a recommendation to use one over the other. If you are not going
to bind the collection to any objects should an ArrayList be used? Is there
a benefit on size? If I have a 200,000 rows of data, should a DataTable be
used in this case?

Any information or experiences would be greatful.

-StinkyDuck
Nov 3 '07 #2

P: n/a
Hi,

If you use VB 200/2003, then you can use an own class build with collection
base.

Otherwise are generics the way to go for this amounts of rows of data in
memory.

http://msdn2.microsoft.com/en-us/library/ms172192.aspx

However what you want to do with 200.000 rows of data in memory. Try to
leave as much as possible on your server, it will cost you a lot of time to
load.

The raw arraylist is only fine with only one field, by instance strings.

Cor

Nov 3 '07 #3

P: n/a
StinkyDuck wrote:
I'm trying to determine which type of collection to use, DataTable or
ArrayList. I understand that an ArrayList can be linked to databound
objects if it contains the IList interface.

Is there a recommendation to use one over the other. If you are not going
to bind the collection to any objects should an ArrayList be used? Is there
a benefit on size? If I have a 200,000 rows of data, should a DataTable be
used in this case?

Any information or experiences would be greatful.
First of all you should look at how to elliminate the amount of data.
You should fetch only the data that you actually use. You are never
going to show 200,000 items simultaneously, as they simply doesn't fit
on the screen. If you ever show more than a few hundred items, there is
something wrong with your user interface.

After that, it's more a matter of taste.

--
Göran Andersson
_____
http://www.guffa.com
Nov 3 '07 #4

P: n/a
This is getting interesting. Let me explain what I'm trying to accomplish
and maybe you guys can provide your ideas. I'm trying to pull out data from
a 3rd party application which provides an API. The primary communcation
with the API are with XML messages. What I'm trying to do is query the 3rd
party database via the API where I get XML response messages. I pull out
the pertinent data from the XML file(s) and store it in memory. I have 5 or
6 memory tables which I need to perform some cross referencing to get to the
data that I actually need. I then take the aggregated data and build an
Excel spreadsheet to persist the data there.

I would be interested to know how someone else would handle this situation.
So basically I have XML files that contain 100 to 200,000 rows of
information. Walking through each XML file do I store the data in an
ArrayList or DataTable? I don't have to update the DataTable/ArrayList. I
just have to search through it to pull out and run some calculations from
each list.

-StinkyDuck
"StinkyDuck" <st********@gmail.comwrote in message
news:O$****************@TK2MSFTNGP03.phx.gbl...
I'm trying to determine which type of collection to use, DataTable or
ArrayList. I understand that an ArrayList can be linked to databound
objects if it contains the IList interface.

Is there a recommendation to use one over the other. If you are not going
to bind the collection to any objects should an ArrayList be used? Is
there a benefit on size? If I have a 200,000 rows of data, should a
DataTable be used in this case?

Any information or experiences would be greatful.

-StinkyDuck

Nov 4 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.