By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,219 Members | 2,140 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,219 IT Pros & Developers. It's quick & easy.

Array to Dataset

P: n/a
I have an array and would like to convert it to dataset. How do I do it?
Please help. Thanks
Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi John,

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

Cor
Nov 20 '05 #2

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.