Array to Dataset

  • Thread starter Thread starter John
  • Start date Start date
J

John

I have an array and would like to convert it to dataset. How do I do it?
Please help. Thanks
 
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.
 
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

"
 
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
 
Back
Top