473,396 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

dataset table into an array list

How to put a specified dataset table into an array list ?

Hrcko
Nov 17 '05 #1
13 11265
arrayList.Add("myArrayList", dSet.Tables["MyTable"]);
"Hrvoje Voda" <hr*********@luatech.com> wrote in message
news:d7**********@ss405.t-com.hr...
How to put a specified dataset table into an array list ?

Hrcko

Nov 17 '05 #2
I managed to fill an array, but I don't konw how to get a real informations
from that array.

When I try to fill a list with items from that array, I get:
System.Collections.ArrayList,
and not the actual data.

This is the code:

ArrayList arrayList = new ArrayList();
arrayList.Add (db.dataSetUsers.Functions);

list.Items.Add(arrayList);

Hrcko
"Adam Barker" <adam@NO******@q-state.co.NO_SPAM.uk> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
arrayList.Add("myArrayList", dSet.Tables["MyTable"]);
"Hrvoje Voda" <hr*********@luatech.com> wrote in message
news:d7**********@ss405.t-com.hr...
How to put a specified dataset table into an array list ?

Hrcko


Nov 17 '05 #3
"Hrvoje Voda" wrote...
I managed to fill an array, but I don't konw how to get
a real informations from that array.
It's a bit confusing when you're using the word "array" when you mean an
ArrayList (and v.v.)...
When I try to fill a list with items from that array,
I get: System.Collections.ArrayList, and not the actual data.
That is because you didn't "fill" the list with the actual items, but with
the ArrayList instance.

(I'm guessing that you really don't mean a "list", but a ListBox...)
list.Items.Add(arrayList);
I'm not even sure you've got the contents of the ArrayList right, as I guess
you "filled" it with some kind of collection of items, and not the items
themselves?
arrayList.Add (db.dataSetUsers.Functions);


So, what does the property "db.dataSetUsers.Functions" actually return?

If it's some collection implementing the interface ICollection, I guess you
rather want to use AddRange instead:

arrayList.AddRange (db.dataSetUsers.Functions);

....and similarily when you put the *contents* of the ArrayList into the
ListBox:

list.Items.AddRange( arrayList.ToArray() );

There's even a possibility that you could skip the intermediate step of
using the ArrayList, depending on what other use you have for it, and what
kind of collection "db.dataSetUsers.Functions" is.

Something like this should be possible:

list.Items.Add( db.dataSetUsers.Functions.ToArray() );

....but as I said, that's depending on which type of collection the Functions
property really is...
// Bjorn A
Nov 17 '05 #4
Functions is a name of the table in dataset.

So, when I user ArrayList.AddRange it's an error.
"Bjorn Abelli" <bj**********@DoNotSpam.hotmail.com> wrote in message
news:OH**************@tk2msftngp13.phx.gbl...
"Hrvoje Voda" wrote...
I managed to fill an array, but I don't konw how to get
a real informations from that array.


It's a bit confusing when you're using the word "array" when you mean an
ArrayList (and v.v.)...
When I try to fill a list with items from that array,
I get: System.Collections.ArrayList, and not the actual data.


That is because you didn't "fill" the list with the actual items, but with
the ArrayList instance.

(I'm guessing that you really don't mean a "list", but a ListBox...)
list.Items.Add(arrayList);


I'm not even sure you've got the contents of the ArrayList right, as I
guess you "filled" it with some kind of collection of items, and not the
items themselves?
arrayList.Add (db.dataSetUsers.Functions);


So, what does the property "db.dataSetUsers.Functions" actually return?

If it's some collection implementing the interface ICollection, I guess
you rather want to use AddRange instead:

arrayList.AddRange (db.dataSetUsers.Functions);

...and similarily when you put the *contents* of the ArrayList into the
ListBox:

list.Items.AddRange( arrayList.ToArray() );

There's even a possibility that you could skip the intermediate step of
using the ArrayList, depending on what other use you have for it, and what
kind of collection "db.dataSetUsers.Functions" is.

Something like this should be possible:

list.Items.Add( db.dataSetUsers.Functions.ToArray() );

...but as I said, that's depending on which type of collection the
Functions property really is...
// Bjorn A

Nov 17 '05 #5

"Hrvoje Voda" wrote...
Functions is a name of the table in dataset.

So, when I user ArrayList.AddRange it's an error.
Of course it does, as DataTable doesn't implement ICollection.

From your sparse comments one couldn't tell if the data from the table
already was "transformed" or "converted" in some way to a collection,
reachable from the property db.dataSetUsers.Functions...

So what you're saying is that db.dataSetUsers.Functions returns a DataTable?

You still haven't said if you wanted the table as one single item in the
ArrayList, or if you wanted the rows from the table to appear as items in
the ArrayList...

If you want the table juat as a single item, you can still use the
"Add"-method (though it doesn't make much sense), but if you want the rows
as separate items, you will most likely need to iterate through the table,
and "Add" each item, e.g.

foreach (DataRow dr in db.dataSetUsers.Functions.Rows)
{
// Form the row into something suitable
// to be used in the ArrayList and/or ListBox
// and add it...
}
// Bjorn A

"Bjorn Abelli" wrote...
"Hrvoje Voda" wrote...
I managed to fill an array, but I don't konw how to get
a real informations from that array.


It's a bit confusing when you're using the word "array" when you mean an
ArrayList (and v.v.)...
When I try to fill a list with items from that array,
I get: System.Collections.ArrayList, and not the actual data.


That is because you didn't "fill" the list with the actual items, but
with the ArrayList instance.

(I'm guessing that you really don't mean a "list", but a ListBox...)
list.Items.Add(arrayList);


I'm not even sure you've got the contents of the ArrayList right, as I
guess you "filled" it with some kind of collection of items, and not the
items themselves?
arrayList.Add (db.dataSetUsers.Functions);


So, what does the property "db.dataSetUsers.Functions" actually return?

If it's some collection implementing the interface ICollection, I guess
you rather want to use AddRange instead:

arrayList.AddRange (db.dataSetUsers.Functions);

...and similarily when you put the *contents* of the ArrayList into the
ListBox:

list.Items.AddRange( arrayList.ToArray() );

There's even a possibility that you could skip the intermediate step of
using the ArrayList, depending on what other use you have for it, and
what kind of collection "db.dataSetUsers.Functions" is.

Something like this should be possible:

list.Items.Add( db.dataSetUsers.Functions.ToArray() );

...but as I said, that's depending on which type of collection the
Functions property really is...
// Bjorn A


Nov 17 '05 #6
I tried to put all that I could remember into
foreach()
{
...
}

but I just can't find a code that will put a column names into an ArrayList.

Hrcko
"Bjorn Abelli" <bj**********@DoNotSpam.hotmail.com> wrote in message
news:ON***************@tk2msftngp13.phx.gbl...

"Hrvoje Voda" wrote...
Functions is a name of the table in dataset.

So, when I user ArrayList.AddRange it's an error.


Of course it does, as DataTable doesn't implement ICollection.

From your sparse comments one couldn't tell if the data from the table
already was "transformed" or "converted" in some way to a collection,
reachable from the property db.dataSetUsers.Functions...

So what you're saying is that db.dataSetUsers.Functions returns a
DataTable?

You still haven't said if you wanted the table as one single item in the
ArrayList, or if you wanted the rows from the table to appear as items in
the ArrayList...

If you want the table juat as a single item, you can still use the
"Add"-method (though it doesn't make much sense), but if you want the rows
as separate items, you will most likely need to iterate through the table,
and "Add" each item, e.g.

foreach (DataRow dr in db.dataSetUsers.Functions.Rows)
{
// Form the row into something suitable
// to be used in the ArrayList and/or ListBox
// and add it...
}
// Bjorn A

"Bjorn Abelli" wrote...
"Hrvoje Voda" wrote...

I managed to fill an array, but I don't konw how to get
a real informations from that array.

It's a bit confusing when you're using the word "array" when you mean an
ArrayList (and v.v.)...

When I try to fill a list with items from that array,
I get: System.Collections.ArrayList, and not the actual data.

That is because you didn't "fill" the list with the actual items, but
with the ArrayList instance.

(I'm guessing that you really don't mean a "list", but a ListBox...)

list.Items.Add(arrayList);

I'm not even sure you've got the contents of the ArrayList right, as I
guess you "filled" it with some kind of collection of items, and not the
items themselves?

arrayList.Add (db.dataSetUsers.Functions);

So, what does the property "db.dataSetUsers.Functions" actually return?

If it's some collection implementing the interface ICollection, I guess
you rather want to use AddRange instead:

arrayList.AddRange (db.dataSetUsers.Functions);

...and similarily when you put the *contents* of the ArrayList into the
ListBox:

list.Items.AddRange( arrayList.ToArray() );

There's even a possibility that you could skip the intermediate step of
using the ArrayList, depending on what other use you have for it, and
what kind of collection "db.dataSetUsers.Functions" is.

Something like this should be possible:

list.Items.Add( db.dataSetUsers.Functions.ToArray() );

...but as I said, that's depending on which type of collection the
Functions property really is...
// Bjorn A



Nov 17 '05 #7

"Hrvoje Voda" wrote...
I tried to put all that I could remember into
foreach()
{
...
}

but I just can't find a code that will put a
column names into an ArrayList.


If you want the column name from a specific column, you can get it through
its index, e.g.:

DataColumnCollection columns =
db.dataSetUsers.Functions.Columns;

for (int i = 0; i < columns.Count; i++)
{
string colname = columns[i].ColumnName;
// do something with the column name
}
// Bjorn A
Nov 17 '05 #8
Sorry, it's not column names but row names.
I tried to put DataRowCollection...
but I don't know how to get the row name.

Hrcko

"Bjorn Abelli" <bj**********@DoNotSpam.hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...

"Hrvoje Voda" wrote...
I tried to put all that I could remember into
foreach()
{
...
}

but I just can't find a code that will put a
column names into an ArrayList.


If you want the column name from a specific column, you can get it through
its index, e.g.:

DataColumnCollection columns =
db.dataSetUsers.Functions.Columns;

for (int i = 0; i < columns.Count; i++)
{
string colname = columns[i].ColumnName;
// do something with the column name
}
// Bjorn A

Nov 17 '05 #9

"Hrvoje Voda" wrote...
Sorry, it's not column names but row names.
I tried to put DataRowCollection...
but I don't know how to get the row name.


I don't understand what you mean here.

DataRows doesn't have names...

// Bjorn A
Nov 17 '05 #10
I don't want to get the names of columns but of their rows.

For example: The name of the column is FunctionName,
but in the row is "Function for all".

Hrcko
"Bjorn Abelli" <bj**********@DoNotSpam.hotmail.com> wrote in message
news:%2******************@TK2MSFTNGP14.phx.gbl...

"Hrvoje Voda" wrote...
Sorry, it's not column names but row names.
I tried to put DataRowCollection...
but I don't know how to get the row name.


I don't understand what you mean here.

DataRows doesn't have names...

// Bjorn A

Nov 17 '05 #11

"Hrvoje Voda" wrote...
I don't want to get the names of columns but of their rows.

For example: The name of the column is FunctionName,
but in the row is "Function for all".


Let's see if I got this right...

So you *know* the column name...

You want the *content* of the column "FunctionName" from each row...

And then you want to add that to an ArrayList...

You could try this:

foreach (DataRow row in db.dataSetUsers.Functions.Rows)
{
string x = row["FunctionName"].ToString();
arrayList.Add ( x );
}
// Bjorn A
Nov 17 '05 #12
I tried that,

but when I fill a listbox with that arrayList I get :
System.Collection.ArrayList
"Bjorn Abelli" <bj**********@DoNotSpam.hotmail.com> wrote in message
news:uI**************@TK2MSFTNGP10.phx.gbl...

"Hrvoje Voda" wrote...
I don't want to get the names of columns but of their rows.

For example: The name of the column is FunctionName,
but in the row is "Function for all".


Let's see if I got this right...

So you *know* the column name...

You want the *content* of the column "FunctionName" from each row...

And then you want to add that to an ArrayList...

You could try this:

foreach (DataRow row in db.dataSetUsers.Functions.Rows)
{
string x = row["FunctionName"].ToString();
arrayList.Add ( x );
}
// Bjorn A

Nov 17 '05 #13

"Hrvoje Voda" <hr*********@luatech.com> skrev i meddelandet
news:d7**********@ss405.t-com.hr...
I tried that,

but when I fill a listbox with that arrayList I get :
System.Collection.ArrayList


Then you missed what I said previously in this thread...

list.Items.AddRange(arraylist);
// Bjorn A
Nov 17 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Alex Ayzin | last post by:
Hi, I have a problem that might be easy to solve(possibly, I've just overlooked an easy solution). Here we go: I have a dataset with 2 datatables in it. Now, I need to do the following: if...
4
by: Filippo Pandiani | last post by:
I have a grid that shows the file list from a folder. On the postback, how do I get a Dataset from this grid? Thanks, Filippo.
13
by: Adie | last post by:
Hi, is this not possible? public DataSet getDimensions() { } public SqlDataReader getDimensions() { }
7
by: samoore33 | last post by:
I want to list all of the items in a dataset in a textbox. The dataset has multiple tables. When I try to use the code below, even though I dim myState as the DataTable("state"). It still looks for...
4
by: David | last post by:
Hi, (Sorry for duplicate post, finger trouble before I finished...) using C# 1.1 I am writing a winform app that collects a dataset from a webservice. At the same time I collect the data,...
15
by: Joseph Geretz | last post by:
I'm a bit puzzled by the current recommendation not to send Datasets or Datatables between application tiers. http://support.microsoft.com/kb/306134 ...
9
by: =?Utf-8?B?Sm9obiBSZWV2ZQ==?= | last post by:
How to put a list of rows from dataset table into an array ? I tried with this code but it doesn't help. ArrayList arrayList = new ArrayList(); foreach (DataRow dr in...
3
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
In Visual Studio 2005, I have my DataSet filled with several static tables (they might get changed weekly, but that's about it). With one of these tables in the DataSet, is it possible to select...
5
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.