B
Bill S.
Can somebody please help. I'm coming from VB6 and this is my first VB.NET
applciation.
Below is my code that fills two tables contained in a DataSet, creates a
relation between them, and finally, uses them as DataSources for two grid
controls on the form. This code works prefectly fine. Now, my question is
how do I apply a DataView in order to sort and filter my data without
destroying my relation? Ever snippet of code I've looked at involves setting
up a DataView and then setting it to the DataSource of my DataGrid. This,
however, destroys my relation.
Thanks for any help.
m_Ds = New DataSet
m_Da1 = New OleDbDataAdapter("SELECT * FROM Groups", Conn)
m_Da2 = New OleDbDataAdapter("SELECT * FROM Clients", Conn)
m_Da1.FillSchema(m_Ds, SchemaType.Source, "Groups")
m_DgGroupsCount = m_Da1.Fill(m_Ds, "Groups")
m_Da2.FillSchema(m_Ds, SchemaType.Source, "Clients")
m_Da2.Fill(m_Ds, "Clients")
'Create a relation and add it to the collection.
Dim rel1 As New DataRelation("LinkToClients", _
m_Ds.Tables("Groups").Columns("GroupID"), _
m_Ds.Tables("Clients").Columns("GroupID"))
m_Ds.Relations.Add(rel1)
'Master/detail setup.
Me.dgGroups.DataSource = m_Ds
Me.dgGroups.DataMember = "Groups"
Me.dgGroups.AllowNavigation = False
Me.dgClients.DataSource = m_Ds
Me.dgClients.DataMember = "Groups.LinkToClients"
applciation.
Below is my code that fills two tables contained in a DataSet, creates a
relation between them, and finally, uses them as DataSources for two grid
controls on the form. This code works prefectly fine. Now, my question is
how do I apply a DataView in order to sort and filter my data without
destroying my relation? Ever snippet of code I've looked at involves setting
up a DataView and then setting it to the DataSource of my DataGrid. This,
however, destroys my relation.
Thanks for any help.
m_Ds = New DataSet
m_Da1 = New OleDbDataAdapter("SELECT * FROM Groups", Conn)
m_Da2 = New OleDbDataAdapter("SELECT * FROM Clients", Conn)
m_Da1.FillSchema(m_Ds, SchemaType.Source, "Groups")
m_DgGroupsCount = m_Da1.Fill(m_Ds, "Groups")
m_Da2.FillSchema(m_Ds, SchemaType.Source, "Clients")
m_Da2.Fill(m_Ds, "Clients")
'Create a relation and add it to the collection.
Dim rel1 As New DataRelation("LinkToClients", _
m_Ds.Tables("Groups").Columns("GroupID"), _
m_Ds.Tables("Clients").Columns("GroupID"))
m_Ds.Relations.Add(rel1)
'Master/detail setup.
Me.dgGroups.DataSource = m_Ds
Me.dgGroups.DataMember = "Groups"
Me.dgGroups.AllowNavigation = False
Me.dgClients.DataSource = m_Ds
Me.dgClients.DataMember = "Groups.LinkToClients"