Results 1 to 2 of 2

Thread: Datarow

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954

    Datarow

    I got this code off of another site (it was in c# orginally) and I moved it to vb.net. But it does not like the line:

    r(0) = dt.Columns(k).ToString()

    I get the error: Value of type 'String' cannot be converted to 'System.Data.DataRow'.



    Code:
        Function FlipDataSet(ByVal my_DataSet As DataSet) As DataSet
            Dim ds As New DataSet()
            Dim dt As New DataTable()
            Dim k, j, i As Integer
    
    
            For Each dt In my_DataSet.Tables
                Dim table As New DataTable()
                For i = 0 To dt.Rows.Count
                    table.Columns.Add(Convert.ToString(i))
                    For k = 0 To dt.Columns.Count
                        Dim r As DataRow()
                        r(0) = dt.Columns(k).ToString()
                        For j = 1 To dt.Rows.Count
                            r(j) = dt.Rows(j - 1)(k)
                        Next
                        table.Rows.Add(r)
                    Next
                    ds.Tables.Add(table)
                Next
                FlipDataSet = ds
            Next
        End Function
    Any thoughts?

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    anyone?

Posting Permissions

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



Click Here to Expand Forum to Full Width