How to populate DataTable/DataSet with Array?

  • Thread starter Thread starter Madan Bharadwaj via .NET 247
  • Start date 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
 
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?
 
Back
Top