array to datatable

Results 1 to 2 of 2

Thread: array to datatable

  1. #1
    Join Date
    Dec 1969

    Default array to datatable

    I have a single dimensional array and how do I create a datatable and insert the values of this array in this datatable of a dataset.<BR>The DataTable will have rows depending upon the length of the array and columns depending upon the elements of the array which are separated by a colon(:)<BR>Thank you.

  2. #2
    Join Date
    Dec 1969

    Default RE: array to datatable

    A DataTable&#039;s Rows collection had an add method which you can use, passing in an array of objects, so if you have dilimited string such as this:<BR><BR>string columnData = "1&#124Jay Nathan&";<BR><BR>... you can split on the pipe character and construct a new row like this:<BR><BR>YourDataTable.Rows.Add(columnData.Spl it(&#039;&#124&#039;));<BR><BR>You will probably want to programmatically construct the columns (i.e. data types, field names, etc...) before you start adding rows.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts