473,386 Members | 1,819 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,386 software developers and data experts.

How to convert datatable into an arraylist

I have a very simple datatable of 1 column which I retrieve from a
database, call it 'data'.

Dim data As Data.DataTable
data = myobject.mymethod(parameter)

I want to now turn this 'data' into an arraylist and I don't know how.
Can anyone help?

And finally I want to convert the arraylist to a 'string array' which I
think can be done by:

Dim ListArray As String() = List.ToArray(GetType(String))

Please help in vb.net code. I am using asp.net 2.0 if that makes any
difference.

Nov 19 '05 #1
2 31421
I doubt you'll find a way to implicitely conver it. You'll need to loop
through and add

dim Listas new ArrayList(data.Rows.Count)
for each row as DataRow in data.Rows
List.Add(row(0))
next

ur convert to string is fine, you'll need to
ctype(List.ToArray(GetType(String), string()) (cast to string array) more
than likely

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/

"Steve" <ba****@iranmania.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
I have a very simple datatable of 1 column which I retrieve from a
database, call it 'data'.

Dim data As Data.DataTable
data = myobject.mymethod(parameter)

I want to now turn this 'data' into an arraylist and I don't know how.
Can anyone help?

And finally I want to convert the arraylist to a 'string array' which I
think can be done by:

Dim ListArray As String() = List.ToArray(GetType(String))

Please help in vb.net code. I am using asp.net 2.0 if that makes any
difference.

Nov 19 '05 #2
Thank you Karl. I think this should do it. As you say, it's a pitty
there isn't a simple built in method to turn a datatable into an array.

Nov 19 '05 #3

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

Similar topics

2
by: mimi | last post by:
I would like to convert an arraylist to dataset or datatable so that I can filter or make a select distinct from it. How to do it? Can someone show me the syntax? Thanks
1
by: George | last post by:
I am wondering what is the cost of using DataTable. Lets say i have 1000 Employee records. The object oriented purist will require the Data Layer to return an ArrayList with 1000 Employee objects....
6
by: gane kol | last post by:
Hi, I have a code that creates a datatable from an arraylist, but i am getting an error in casting in for (int intRow = 0; intRow < alLCPlist.Count; intRow++) { DataRow drow =...
1
by: Joseph | last post by:
Hi all, I know that you can convert a Dataset into an Arraylist, I was wondering if it is possible to do the opposite - Convert an Arraylist to a Dataset? If so, how do you do this? An example...
3
by: David | last post by:
Hi all, I am following this code... http://www.devarticles.com/c/a/C-Sharp/Interface-IEnumerable-and-IEnumerator-in-C-sharp/2/ I have come to the part with public Customers(). I am assuming...
15
by: =?Utf-8?B?cm9nZXJfMjc=?= | last post by:
hey, I have a datatable here, but I need to make it into a string array. how do I do that?
4
by: =?Utf-8?B?YmFzdWxhc3o=?= | last post by:
Hi; I want to store a datatable (or an arraylist) as a session variable but when I try; Session = al_RecNo; I get an error that; "Cannot implicitly convert type...
4
by: StinkyDuck | last post by:
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...
2
by: Mr. Arnold | last post by:
I am working a C# project that uses what's in the subject. I kind of have the basics down on reading the table data. I don't use the above methods of data access or persistence, but I am stuck...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...

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.