How to populate DataTable/DataSet with Array?

  • Thread starter Madan Bharadwaj via .NET 247
  • Start date
M

Madan Bharadwaj via .NET 247

Hi,
How do I populate a DataTable (or a DataSet) with values from an Array?

Code:
Dim myObject as String
Dim myTable As New DataTable

ReDim myObject (10, 10)

' Populate myObject with values here

' How to do the equivalent of the following command
' myTable.Data = myObject

Is the only way to do this is using a loop to collect every element and update a DataRow and insert the DataRow into the DataTable?

Thanks in advance.
Madan
 
M

Miha Markic [MVP C#]

Hi Madan,

DataRow.ItemArray might help you, though it is still row based.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Madan Bharadwaj via .NET 247 said:
Hi,
How do I populate a DataTable (or a DataSet) with values from an Array?

Code:
Dim myObject as String
Dim myTable As New DataTable

ReDim myObject (10, 10)

' Populate myObject with values here

' How to do the equivalent of the following command
' myTable.Data = myObject

Is the only way to do this is using a loop to collect every element and
update a DataRow and insert the DataRow into the DataTable?
 

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

Top