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


Top 5 Contributors of the Month
satyapriyanayak
Sambanthamoorthy

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  
 

Hi,

 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

Cheers
Pankaj


     

Further Readings:

Responses

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