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 John,

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

Cor
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

array in dataset 4
How to Convert EML to PST? 2
by any chance... 3
Translate C# to VB.net? 7
Compare Datasets or Arrays 4
Write binary data to database 1
2D array of string 8
Dataset to XML 2

Back
Top