.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Imran Ghani

Home >> Code Snippets >> Collections >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Convert Array into DataTable

Posted By:Pankaj Mishra       Posted Date: August 07, 2008    Points: 10    Category: Collections    URL: http://www.dotnetspark.com  


 Below method is used to convert Array into DataTable. All you have to use LoadDataRow() method of DataTable to convert Array to DataTable.

Lets see the method.

The code example is based on C#.

public static DataTable GetDataTableFromArray(object[] array)


DataTable dataTable = new DataTable();

dataTable.LoadDataRow(array, true);//Pass array object to LoadDataRow method

return dataTable;


VB.Net Example

Public Shared Function GetDataTableFromArray(ByVal array As Object()) As DataTable

Dim dataTable As New DataTable()

dataTable.LoadDataRow(array, True)'Pass array object to LoadDataRow method

Return dataTable

End Function



Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend