Connecting Tech Pros Worldwide Forums | Help | Site Map

Parent and Child Datagrid problem

Member
 
Join Date: Jul 2008
Posts: 77
#1: Aug 11 '08
Expand|Select|Wrap|Line Numbers
  1. Private Sub frmSearch_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2.         Dim sql1 As String
  3.         Dim sql2 As String
  4.         Dim da1 As SqlDataAdapter
  5.         Dim da2 As SqlDataAdapter
  6.         Dim con As SqlConnection
  7.         Dim ds As New DataSet
  8.  
  9.  
  10.         con = New SqlConnection(StrCon)
  11.         con.Open()
  12.         sql1 = "SELECT     dbo.tbl_Case.CaseID, dbo.tbl_Case.CaseIDText, dbo.tbl_Client.FirstName, dbo.tbl_Client.ClientID, dbo.tbl_Client.Role
  13. FROM         dbo.tbl_Case INNER JOIN
  14.                       dbo.tbl_Client ON dbo.tbl_Case.CaseID = dbo.tbl_Client.CaseID
  15. WHERE     (dbo.tbl_Client.Role = N'Ini')
  16.  
  17.         sql2 = ""SELECT     dbo.tbl_Case.CaseID, dbo.tbl_Case.CaseIDText, dbo.tbl_Client.FirstName, dbo.tbl_Client.ClientID, dbo.tbl_Client.Role
  18. FROM         dbo.tbl_Case INNER JOIN
  19.                       dbo.tbl_Client ON dbo.tbl_Case.CaseID = dbo.tbl_Client.CaseID
  20. WHERE     (dbo.tbl_Client.Role <> N'Ini')
  21.  
  22.  
  23.         da1 = New SqlDataAdapter(sql1, con)
  24.         da2 = New SqlDataAdapter(sql2, con)
  25.         da1.Fill(ds, "Parent")
  26.         da2.Fill(ds, "Child")
  27.         Dim DataRelation As New DataRelation("Parent", ds.Tables("Parent").Columns("CaseID"), ds.Tables("Child").Columns("CaseID"))
  28.         ds.Relations.Add(DataRelation)
  29.         Dim dv As New DataView(ds.Tables("Parent"))
  30.  
  31.         dgSearch.DataSource = dv
  32.  
  33.  
  34.     End Sub
  35.  
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.

Member
 
Join Date: Jul 2008
Posts: 77
#2: Aug 11 '08

re: Parent and Child Datagrid problem


I found it.
I was using datagridview instead of datagrid.
Reply