-1

データセットをデータテーブルとして作成しましたが、グラフに表示するデータテーブルをさらに 3 つ取得する必要がありますが、3 回すべて実行するには、関数を作成して元のデータテーブルから呼び出すことができると言われました。しかし、既存のデータテーブルをどのように呼び出すのでしょうか?

私のコードは次のとおりです。

    Dim a As DataSet = information
    Dim abc As DataTable
    abc = a.Tables(0)

    Dim array As New ArrayList
    Dim array1 As New ArrayList

    For Each row In first
        array.Add(row("data"))
    Next row

    For Each row In second
        array1.Add(row("data"))
    Next row

    For Each row In third
        array2.Add(row("data"))
    Dim serializer As New JavaScriptSerializer()
    Dim arrayJson As String = serializer.Serialize(array)
End Sub

これを使用して、新しい関数を作成して新しいデータセットをコピーして貼り付ける必要がないようにするにはどうすればよいですか?

これまでのところ、

Function information() As DataTable
    Dim array As New ArrayList
    For Each row In forth
        array.Add(row("data"))
    Next row
End Function

どこか間違ってる…

4

2 に答える 2

2

このようなものがあなたが求めているものだと思います。すべての行とそれぞれのすべてDataTablesの行を列挙し、データ列の情報を配列リストに追加します。DataSetDataTable

Dim ds As DataSet = information 'populate the DataSet with data
Dim arr(ds.Tables.Count - 1) As New ArrayList 'define an Array of ArrayLists to hold the data 

'Loop through each Table and put the data into the appropriate ArrayList
For i As Integer = 0 To ds.Tables.Count - 1
    For Each dr As DataRow in ds.Tables(i).Rows
        arr(i).Add(dr("data"))
    Next
    'Do whatever you want with the arr here...
Next
于 2013-07-01T15:40:22.983 に答える