467,911 Members | 1,430 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,911 developers. It's quick & easy.

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
  • viewed: 13173
Share:
2 Replies
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Pavel Novotny | last post: by
reply views Thread by Thaddeus | last post: by
1 post views Thread by Somebody_Out_There | last post: by
4 posts views Thread by Tamir Khason | last post: by
3 posts views Thread by NuB | last post: by
9 posts views Thread by B. Salmon | last post: by
2 posts views Thread by Brett Romero | last post: by
2 posts views Thread by karups | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.