473,667 Members | 2,557 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 13372
how about this:

DataSet dsTemp = new DataSet();
DataTable Tables = new DataTable();
dsTemp.Tables.A dd(Tables);

dsTemp.Tables[0].Columns.Add( "val", System.Type.Get Type(
"System.Str ing" ) );

foreach(string str in arraylistcontai ner)
{

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******** ******@TK2MSFTN GP11.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******* *******@TK2MSFT NGP11.phx.gbl>. ..
how about this:

DataSet dsTemp = new DataSet();
DataTable Tables = new DataTable();
dsTemp.Tables.A dd(Tables);

dsTemp.Tables[0].Columns.Add( "val", System.Type.Get Type(
"System.Str ing" ) );

foreach(string str in arraylistcontai ner)
{

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******** ******@TK2MSFTN GP11.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, 6124080|PRIRUBA 11 DN200 PN6;CSN131160.0;11369.1;CSN131005.50|KS|8,870000|2761, I dont know how convert it to dataset or XML... Is there any function in .NEt or must I implement myself
0
10253
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 recordset conversion. //Get RecordSet from Dataset //ds2rs DataSet2RecordSet
1
6818
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 are dynamic which means that I am right now creating the schema/structure of the datatable from a datareader using reader.GetSchemaTable() and then looping thru the reader to populate values. Is there any other efficient way of achieving this?...
4
50775
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); //Error here: Argument '1': cannot convert from 'System.Windows.Forms.Menu.MenuItemCollection' to 'System.Windows.Forms.MenuItem' So please advice.
3
4024
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 it.
9
6839
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 to use the OleDbDataAdapter.Fill method, but I could only get that to work if I gave it an ADODB::RecordsetClass object. I couldn't figure out how to get an ADO _Recordset into an ADODB::RecordsetClass. Any ideas? I don't want to have to...
2
1146
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 fill these results into my local dataset. How can I get these results into the local dataset? I need the results place into a dataset to allow working with DataGridTableStyle for grid formatting. Thanks,
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
8457
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8365
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8883
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8788
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8563
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7390
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4200
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1778
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.