Parent and Child Datagrid problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sep410
    New Member
    • Jul 2008
    • 77

    Parent and Child Datagrid problem

    Code:
    Private Sub frmSearch_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim sql1 As String
            Dim sql2 As String
            Dim da1 As SqlDataAdapter
            Dim da2 As SqlDataAdapter
            Dim con As SqlConnection
            Dim ds As New DataSet
    
    
            con = New SqlConnection(StrCon)
            con.Open()
            sql1 = "SELECT     dbo.tbl_Case.CaseID, dbo.tbl_Case.CaseIDText, dbo.tbl_Client.FirstName, dbo.tbl_Client.ClientID, dbo.tbl_Client.Role
    FROM         dbo.tbl_Case INNER JOIN
                          dbo.tbl_Client ON dbo.tbl_Case.CaseID = dbo.tbl_Client.CaseID
    WHERE     (dbo.tbl_Client.Role = N'Ini')
    
            sql2 = ""SELECT     dbo.tbl_Case.CaseID, dbo.tbl_Case.CaseIDText, dbo.tbl_Client.FirstName, dbo.tbl_Client.ClientID, dbo.tbl_Client.Role
    FROM         dbo.tbl_Case INNER JOIN
                          dbo.tbl_Client ON dbo.tbl_Case.CaseID = dbo.tbl_Client.CaseID
    WHERE     (dbo.tbl_Client.Role <> N'Ini')
    
    
            da1 = New SqlDataAdapter(sql1, con)
            da2 = New SqlDataAdapter(sql2, con)
            da1.Fill(ds, "Parent")
            da2.Fill(ds, "Child")
            Dim DataRelation As New DataRelation("Parent", ds.Tables("Parent").Columns("CaseID"), ds.Tables("Child").Columns("CaseID"))
            ds.Relations.Add(DataRelation)
            Dim dv As New DataView(ds.Tables("Parent"))
    
            dgSearch.DataSource = dv
    
    
        End Sub
    Hi all,

    This is the code that I have and I need to see parent and child record in my datagridview but I only get the parent table in my datagrid.

    what is wrong with my code?

    Please help me.
    Last edited by Curtis Rutland; Aug 11 '08, 08:50 PM. Reason: Added Code Tags - Please use the # button
  • Sep410
    New Member
    • Jul 2008
    • 77

    #2
    I found it.
    I was using datagridview instead of datagrid.

    Comment

    Working...