RobertG35 0 Newbie Poster

I create 2 datatables and add them to the dataset and add the relation. The problem is only the parent table seems to be bound to my gridview.

Any idea of what I might be missing?

Dim connVT As New SqlConnection(ValuTrak.strConnVT)

        Dim strSqlAD As String = "SELECT * FROM test1 "
        Dim strSqlVT As String = "SELECT * FROM test2 "

        Dim da1, da2 As SqlDataAdapter
        Dim ds3 As DataSet
        Dim dt1, dt2 As DataTable

        da1 = New SqlDataAdapter(strSqlAD, connVT)
        da2 = New SqlDataAdapter(strSqlVT, connVT)

        dt1 = New DataTable("test1")
        dt2 = New DataTable("test2")
        ds3 = New DataSet("MergedData")
        Dim columns() As DataColumn
        columns = dt1.PrimaryKey


        Try
            connVT.Open()
            connAD.Open()

            da1.Fill(dt1)
            da2.Fill(dt2)

            Dim keys(1) As DataColumn
            Dim keys2(1) As DataColumn
            keys(0) = dt1.Columns(0)
            keys2(0) = dt2.Columns(0)
            dt1.PrimaryKey = keys
            dt2.PrimaryKey = keys2

            ds3.Tables.Add(dt1)
            ds3.Tables.Add(dt2)
            'ds3.Merge(dt2)

            ds3.Relations.Add("__RELATION__", ds3.Tables(0).Columns(0), ds3.Tables(1).Columns(0), False)

            GridView1.DataSource = ds3
            GridView1.DataBind()

        Catch exc As SqlException
            Response.Write(exc.ToString())
            Server.Transfer("servererror.aspx")
        Finally
            connVT.Dispose()
            connAD.Dispose()
        End Try