How to convert a Collection arraylist to dataset

M

mimi

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
 
A

Alvin Bruney [MVP]

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
 
M

Mimi

Thanks Alvin
Alvin Bruney said:
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 said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top