473,237 Members | 1,257 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,237 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 31415
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: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.