Solved

How to fill a Datatable with an Array.

Posted on 2014-03-24
4
321 Views
Last Modified: 2014-04-13
Hi.

I am working with an external  WebService which  returns an array, but I cant recover the data on it.

I specifically need to recover two columns of the array and insert this values dynamically into a datatable. These colums names in the array are: DescripcionOT and FolioOT.

================= The code  in vb.Net is like this:  ============


 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim sesion_bodega As Integer = 2

        Dim OrdenesDeTrab As Array
        Dim WS_OTS As New WsInfoParaBodegas
        Dim TabOTs As New DataTable


        OrdenesDeTrab = WS_OTS.OrdenesEnEjecucion(2)

        Dim OTs As String
        Dim Desc_OT As String

        OTs = OrdenesDeTrab.Length.ToString

        ' in the debugging image the array.lenght  recovers 3 rows  (OTs= 3)
        ' Here I need to recover the 3 register in the array to fill up a data dable  (TabOTs ) 
        ' the array view is attached in the image. 


    End Sub

Open in new window

Array-values.jpg
0
Comment
Question by:Guvs89
  • 2
4 Comments
 
LVL 26

Expert Comment

by:Shaun Kline
ID: 39952788
Have you tried using <your data table>.Rows.Add(<your array>)?
0
 

Accepted Solution

by:
Guvs89 earned 0 total points
ID: 39986749
Dim OrdenesDeTrab As Array
            Dim WS_OTS As New WsInfoParaBodegas
            Dim TabOTs As New DataTable

            OrdenesDeTrab = WS_OTS.OrdenesEnEjecucion(sesion_bodega)
            TabOTs.Columns.Add("FolioOT", GetType(String))
            TabOTs.Columns.Add("DescripcionOT", GetType(String))

     
            For i As Integer = 0 To Convert.ToInt32(OrdenesDeTrab.Length) - 1

                If Not IsNothing(OrdenesDeTrab(i).DescripcionOT) Then
                    Dim N_reg As DataRow = TabOTs.NewRow
                    N_reg.Item("FolioOT") = OrdenesDeTrab(i).FolioOT.ToString
                    N_reg.Item("DescripcionOT") = OrdenesDeTrab(i).descripcionOT.ToString
                    TabOTs.Rows.Add(N_reg)

                Else

                    Mensaje.Text = " No se encontraron órdenes de trabajo de PSL "

                End If

            Next

            GV_OTs_PSL.DataSource = TabOTs
            GV_OTs_PSL.DataBind()
0
 

Author Closing Comment

by:Guvs89
ID: 39997119
I tryed several ways to recover de array data , by  my own trial and error process.
It  finally it worked.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Calling web service and its methods dynamically 2 59
Class Library Dynamics For Connectstring Information 2 29
List<PaisEntity> - show some 1 24
Expression Evaluater 3 27
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question