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 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
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
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
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());
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.
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
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
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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
|
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.
|
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...
|
by: Hrvoje Voda |
last post by:
How to put a specified dataset table into an array list ?
Hrcko
| |
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |