473,509 Members | 3,095 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dataset Table in Array

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 db.dataSetUsers.Tables["Functions"].Rows)
{
arrayList.Add (dr["Name"]);
}
--
Regards,
John Reeve
Jun 27 '08 #1
9 1632
John Reeve wrote:
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 db.dataSetUsers.Tables["Functions"].Rows)
{
arrayList.Add (dr["Name"]);
}
I don't know exactly what you want, as your code does something
different from what you are asking for. This is closer to what you asked
for:

DataTable table = db.dataSetUsers.Tables["Functions"];
DataRow[] rows = new DataRow[table.Rows.Count];
int i = 0;
foreach (DataRow row in table.Rows) {
rows[i++] = row;
}

--
Göran Andersson
_____
http://www.guffa.com
Jun 27 '08 #2
I want to add the names from database to an arraylist

--
Regards,
John Reeve
"Göran Andersson" wrote:
John Reeve wrote:
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 db.dataSetUsers.Tables["Functions"].Rows)
{
arrayList.Add (dr["Name"]);
}

I don't know exactly what you want, as your code does something
different from what you are asking for. This is closer to what you asked
for:

DataTable table = db.dataSetUsers.Tables["Functions"];
DataRow[] rows = new DataRow[table.Rows.Count];
int i = 0;
foreach (DataRow row in table.Rows) {
rows[i++] = row;
}

--
Göran Andersson
_____
http://www.guffa.com
Jun 27 '08 #3
John Reeve wrote:
I want to add the names from database to an arraylist
That's what your code is doing. In what way is it not helping?

Tip: If you are top posting, you should not have two dashes in your
signature. That is commonly regarded as end of message, so the news
reader removes everything below it. As you are top posting that means
the entire previous conversation.

--
Göran Andersson
_____
http://www.guffa.com
Jun 27 '08 #4
On Jun 10, 1:47*am, John Reeve <john_ree...@hotmail.comwrote:
I want to add the names from database to an arraylist

--
Regards,
John Reeve

"Göran Andersson" wrote:
John Reeve wrote:
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 db.dataSetUsers.Tables["Functions"].Rows)
{
arrayList.Add (dr["Name"]);
}
I don't know exactly what you want, as your code does something
different from what you are asking for. This is closer to what you asked
for:
DataTable table = db.dataSetUsers.Tables["Functions"];
DataRow[] rows = new DataRow[table.Rows.Count];
int i = 0;
foreach (DataRow row in table.Rows) {
* * rows[i++] = row;
}
--
Göran Andersson
_____
http://www.guffa.com- Hide quoted text -

- Show quoted text -
As what? as string?
List<stringnames = new List<string>();
foreach (DataRow row in table.Rows) {
names.Add( row["FirstName"].ToString());
Jun 27 '08 #5
On Jun 10, 7:30*am, Göran Andersson <gu...@guffa.comwrote:
John Reeve wrote:
I want to add the names from database to an arraylist

That's what your code is doing. In what way is it not helping?
Not really, the code just copy the ENTIRE column to an array, not very
useful IMHO.
Jun 27 '08 #6
Ignacio Machin ( .NET/ C# MVP ) wrote:
On Jun 10, 7:30 am, Göran Andersson <gu...@guffa.comwrote:
>John Reeve wrote:
>>I want to add the names from database to an arraylist
That's what your code is doing. In what way is it not helping?

Not really, the code just copy the ENTIRE column to an array, not very
useful IMHO.
That depends on what the OP wants to do, which is what I am trying to
find out...

--
Göran Andersson
_____
http://www.guffa.com
Jun 27 '08 #7
Try renaming the name of the arraylist; and it will works

ArrayList arr = new ArrayList();
foreach (DataRow dr in db.dataSetUsers.Tables["Functions"].Rows)
{
arr.Add (dr["Name"]);
}
Regards,
Mudassar Hassan
http://mudassarhassan.spaces.live.com/
"Göran Andersson" wrote:
Ignacio Machin ( .NET/ C# MVP ) wrote:
On Jun 10, 7:30 am, Göran Andersson <gu...@guffa.comwrote:
John Reeve wrote:
I want to add the names from database to an arraylist
That's what your code is doing. In what way is it not helping?
Not really, the code just copy the ENTIRE column to an array, not very
useful IMHO.

That depends on what the OP wants to do, which is what I am trying to
find out...

--
Göran Andersson
_____
http://www.guffa.com
Jun 27 '08 #8
that works
thanks mudassar

--
Regards
Reeve - the developer

"Mudassar Hassan" wrote:
Try renaming the name of the arraylist; and it will works

ArrayList arr = new ArrayList();
foreach (DataRow dr in db.dataSetUsers.Tables["Functions"].Rows)
{
arr.Add (dr["Name"]);
}
Regards,
Mudassar Hassan
http://mudassarhassan.spaces.live.com/
"Göran Andersson" wrote:
Ignacio Machin ( .NET/ C# MVP ) wrote:
On Jun 10, 7:30 am, Göran Andersson <gu...@guffa.comwrote:
>John Reeve wrote:
>>I want to add the names from database to an arraylist
>That's what your code is doing. In what way is it not helping?
>
Not really, the code just copy the ENTIRE column to an array, not very
useful IMHO.
That depends on what the OP wants to do, which is what I am trying to
find out...

--
Göran Andersson
_____
http://www.guffa.com
Jun 27 '08 #9
Mudassar Hassan wrote:
Try renaming the name of the arraylist; and it will works

ArrayList arr = new ArrayList();
foreach (DataRow dr in db.dataSetUsers.Tables["Functions"].Rows)
{
arr.Add (dr["Name"]);
}
Regards,
Mudassar Hassan
http://mudassarhassan.spaces.live.com/
Why do you think that this would make any difference? Even if it may not
be ideal, the name arrayList is perfectly valid for an instance of the
class ArrayList.

--
Göran Andersson
_____
http://www.guffa.com
Jun 27 '08 #10

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

Similar topics

3
3137
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
1485
by: amber | last post by:
Hello, How can I declare an array, and set it to equal all the items in a column of a dataset? TIA, Amber
4
2833
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.
5
4653
by: Trond | last post by:
I have a webservice that is returning a dataset. In dataset there is a table with 4 columns. (LDate, LTime, LDepth and ServiceNumber) I then try to read only 2 of the columns into array (double...
13
11277
by: Hrvoje Voda | last post by:
How to put a specified dataset table into an array list ? Hrcko
3
2291
by: AFN | last post by:
I need to manually create the data to be shown in a datagrid (or some data table object). Should I create an array and bind the array to the datagrid OR should I create a temporary dataset and...
2
1235
by: Darren Clark | last post by:
I have a data set... in which i need to remove 1 row based on a particaly name eg i have a data set (data) and it has 1 table and N rows.... It has a column name of i want to remove all...
7
1779
by: Bob | last post by:
Hi, I have a typed unbound dataset that is passed to a datahandling class to be filled. The datahandling class fills it from a sproc using an oledbDataAdapter (SQLAnywhere database) The only...
0
3880
by: Johnny | last post by:
I have a PocketPC mobile application that gets its data from the Sql Server database via a web service. The web service returns a dataset that I need to load into the SqlCe database on the mobile...
9
1593
by: Tony Girgenti | last post by:
Hello I developed and tested a web application using VS.NET 2003, VB, .NET Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1. It uses a web form. I tried doing this without any help, but i'm...
0
7234
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7136
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
7344
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7069
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
7505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4730
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3203
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.