473,508 Members | 2,207 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to convert a Collection arraylist to dataset

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
Nov 18 '05 #1
2 13364
how about this:

DataSet dsTemp = new DataSet();
DataTable Tables = new DataTable();
dsTemp.Tables.Add(Tables);

dsTemp.Tables[0].Columns.Add( "val", System.Type.GetType(
"System.String" ) );

foreach(string str in arraylistcontainer)
{

if(str != string.Empty)
{
DataRow myRow = dsTemp.Tables[0].NewRow();
myRow[0]= str;
dsTemp.Tables[0].Rows.Add(myRow);
}

roughly

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"mimi" <mh****@hotmail.com> wrote in message
news:uD**************@TK2MSFTNGP11.phx.gbl...
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

Nov 18 '05 #2
Thanks Alvin
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message news:<#8**************@TK2MSFTNGP11.phx.gbl>...
how about this:

DataSet dsTemp = new DataSet();
DataTable Tables = new DataTable();
dsTemp.Tables.Add(Tables);

dsTemp.Tables[0].Columns.Add( "val", System.Type.GetType(
"System.String" ) );

foreach(string str in arraylistcontainer)
{

if(str != string.Empty)
{
DataRow myRow = dsTemp.Tables[0].NewRow();
myRow[0]= str;
dsTemp.Tables[0].Rows.Add(myRow);
}

roughly

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"mimi" <mh****@hotmail.com> wrote in message
news:uD**************@TK2MSFTNGP11.phx.gbl...
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

Nov 18 '05 #3

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

Similar topics

2
301
by: Pavel Novotny | last post by:
H I'm trying to import a | seperated text from string variable which represents a tabl with several fields, eg 6124079|PRIRUBA 11 DN250 PN6;CSN131160.0;11369.1;CSN131005.50|KS|11,100000|3437,...
0
10222
by: Thaddeus | last post by:
//Author: //Thaddeus Jacobs, MCP //Kinematic Automation, Inc. //mailto:tjacobs@kinematic.com // //Description: //convert ADO .NET dataset to ADO 2.5 2.6 2.7 recordset and v/v //DataSet to...
1
6802
by: Somebody_Out_There | last post by:
Hello, I am trying to create a strongly typed datatable/dataset from an untyped dataset or datatable returned from a stored proc. The structure of the table cannot be static since the results...
4
50747
by: Tamir Khason | last post by:
How can I convert (elegant way) Collection to Array without looping and new instances. E.G: I want to add elements of one menu to other, so secondMenu.MenuItems.AddRange(firstMenu.MenuItems);...
3
4019
by: NuB | last post by:
I have a collection of data, that i'm looping thru and reading and populating a file. Can i make that collection into a dataset so i can then create a dataview, or dataTable to then sort, etc, thru...
9
6833
by: B. Salmon | last post by:
I have a Visual C++ .NET function that is calling an unmanaged function that returns an ADO _Recordset* object. I want to be able to convert that into an ADO.NET DataSet (or DataTable). I tried...
2
1142
by: Brett Romero | last post by:
I use a method that returns either a dataset or a collection depending on the method called. Since no database is involved at the layer I'm working, I can't use a data adapter's fill method to...
2
331
by: karups | last post by:
Hi when i convert Excel file to dataset using the following code, i find that, some col. such as Col1 ------ 404 403 NOT 222
0
7132
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
7336
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,...
0
7401
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...
1
7063
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
7504
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...
0
5640
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,...
1
5059
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
3211
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.