473,385 Members | 1,707 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,385 software developers and data experts.

Array to Dataset

I have an array and would like to convert it to dataset. How do I do it?
Please help. Thanks
Nov 20 '05 #1
5 21923
Hi John,

An array of your own class objects or an array of values?

Cor
Nov 20 '05 #2
Hi Cor,

Just the array of values. I have 3 arrays of values: ary1, ary2 and ary3.

I'd like to have it in the table so column 1 ("Name") uses ary1, column 2
("Value") uses ary2, and column 3 ("Time") uses ary3. Please help.

Thanks very much.
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:OO**************@tk2msftngp13.phx.gbl...
Hi John,

An array of your own class objects or an array of values?

Cor

Nov 20 '05 #3
Hi John,

I type it in here so watch typos

\\\
Dim ds as new dataset
Dim dt as new datatable("JohnsTable")
ds.tables.add(dt)
Dim dc1 as new datacolumn("Name")
Dim dc2 as new datacolumn("Valve")
Dim dc3 as new datacolumn("Time")
dt.columns.add(dc1)
dt.columns.add(dc2)
dt.columns.add(dc3)
for i as integer = 0 to ary1.length-1
dim dr as datarow = dt.newrow
dr("Name") = ary1(i)
dr("Valve") = ary2(i)
dr("Time") = ary3(i)
dt.rows.add(dr)
next
///
This asumes that the arys have all the same lenght and otherwise it will be
impossible in my opinion.

I hope this helps?

Cor

"
Just the array of values. I have 3 arrays of values: ary1, ary2 and ary3.

I'd like to have it in the table so column 1 ("Name") uses ary1, column 2
("Value") uses ary2, and column 3 ("Time") uses ary3. Please help.

Thanks very much.
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:OO**************@tk2msftngp13.phx.gbl...
Hi John,

An array of your own class objects or an array of values?

Cor


Nov 20 '05 #4
So there's no way to do it without going through the loop?
Thanks,
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:OO**************@TK2MSFTNGP10.phx.gbl...
Hi John,

I type it in here so watch typos

\\\
Dim ds as new dataset
Dim dt as new datatable("JohnsTable")
ds.tables.add(dt)
Dim dc1 as new datacolumn("Name")
Dim dc2 as new datacolumn("Valve")
Dim dc3 as new datacolumn("Time")
dt.columns.add(dc1)
dt.columns.add(dc2)
dt.columns.add(dc3)
for i as integer = 0 to ary1.length-1
dim dr as datarow = dt.newrow
dr("Name") = ary1(i)
dr("Valve") = ary2(i)
dr("Time") = ary3(i)
dt.rows.add(dr)
next
///
This asumes that the arys have all the same lenght and otherwise it will be impossible in my opinion.

I hope this helps?

Cor

"
Just the array of values. I have 3 arrays of values: ary1, ary2 and ary3.
I'd like to have it in the table so column 1 ("Name") uses ary1, column 2 ("Value") uses ary2, and column 3 ("Time") uses ary3. Please help.

Thanks very much.
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:OO**************@tk2msftngp13.phx.gbl...
Hi John,

An array of your own class objects or an array of values?

Cor



Nov 20 '05 #5
John,
So there's no way to do it without going through the loop?


Never forget that when you do it not yourself, it is done for you, there is
no other way than moving data item by item in this kind of operations where
the memory positions of that data are not equeal.

Cor
Nov 20 '05 #6

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

Similar topics

0
by: EMiller | last post by:
Hello, I am encountering a development challenge here that seems to be stumping me. I am developing a C#/.NET application using an MSDE database. There is a particular field in a table that I...
1
by: David D. McCrory | last post by:
I have the following that returns an array of a struct and I want to load it into a DataSet on the consumer side.....Can someone provide me with an example of how to use the DataSet.ReadXml()...
2
by: Marty McDonald | last post by:
I have an array of objects (my own custom class). I'm trying to convert that array to a dataset. So I serialize the array to XML, then try to load the XML to a dataset. MemoryStream mem = new...
6
by: Carl | last post by:
Hi, I want to pass an array of object of different type to a function and use it in the function. I am not able to have it working. Function that create the array... public virtual DataSet...
5
by: Trond | last post by:
I have a webservice that is returning a dataset. In dataset there is a table with 4 columns. (LDate, LTime, LDepth and ServiceNumber) I then try to read only 2 of the columns into array (double...
6
by: Michael Rodriguez | last post by:
What is the proper way to declare and initialize an array of datasets? Would it go like this: private DataSet myDataSets; DataSet ds1 = new DataSet(); // initialize the dataset DataSet...
7
by: Jed | last post by:
I have a web service method that returns an array of custom objects marked serializeable with fully described public properties. When I bind the results to a DataGrid I can access the properties...
12
by: Graham Blandford | last post by:
Hi all, Would someone be able to tell me the most 'graceful' way of removing unwanted rows from a dataset based on a condition prior to update? OR, resetting the rows all to unchanged after they...
2
by: =?Utf-8?B?ZGJhMTIz?= | last post by:
Note, I'm using C# I am wondering what type of control I should use for iterating through the set of records returned by callin this method below, so that I can then do some stuff with each...
4
by: vaiism | last post by:
I am trying to write a string compare function using pointers and dynamic arrays, and am having trouble comparing the individual elements of the array contained with the struct. The code below...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.