master/details

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rodchar

    master/details

    Hey all,

    I'm using Northwind Customers and Orders tables. And I'm trying to build a
    3-tier logical architecture app. My problem is I have a form that lists all
    the customers in a datagrid. I want to be able to click on a customer and
    show form 2 with the details of that customer and another datagrid of the
    orders below.

    I'm trying to pass just one business object that has the dataset wrapped in
    it. When I pass the business object to the second form I can't get the
    datagrid to sync with the selected customer. It keeps defaulting I guess to
    the first customer of the customers' table. How can I sync my orders datagrid
    with the selected customer?

    Thanks in advance,
    rodchar
  • Ken Tucker [MVP]

    #2
    Re: master/details

    Hi,

    Here is an example that uses datareleations to keep 3 grids in sync.
    Place 3 datagrid grids on the form dgorders, dgorderdetails, dgemployees.


    Dim ds As DataSet

    Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
    System.EventArg s) Handles MyBase.Load

    Dim daEmployees As OleDbDataAdapte r

    Dim daOrders As OleDbDataAdapte r

    Dim daOrderDetails As OleDbDataAdapte r

    Dim conn As OleDbConnection

    Dim strConn As String

    Dim strSQL As String

    Dim strItem As String

    Dim ctrl As Control

    For Each ctrl In Me.Controls

    If TypeOf ctrl Is DataGrid Then

    Dim dg As DataGrid = ctrl

    dg.AllowNavigat ion = False

    End If

    Next

    strConn = "Provider = Microsoft.Jet.O LEDB.4.0;"

    strConn &= "Data Source = Northwind.mdb;"



    conn = New OleDbConnection (strConn)

    ds = New DataSet

    daEmployees = New OleDbDataAdapte r("Select * from Employees", conn)

    daOrders = New OleDbDataAdapte r("Select * from Orders", conn)

    daOrderDetails = New OleDbDataAdapte r("Select * from [Order Details]", conn)

    daEmployees.Fil l(ds, "Employee")

    daOrders.Fill(d s, "Orders")

    daOrderDetails. Fill(ds, "OrderDetai ls")

    ds.Relations.Ad d("EmployeeOrde r",
    ds.Tables("Empl oyee").Columns( "EmployeeID "), _

    ds.Tables("Orde rs").Columns("E mployeeID"))

    ds.Relations.Ad d("Order2Detail s", ds.Tables("Orde rs").Columns("O rderID"), _

    ds.Tables("Orde rDetails").Colu mns("OrderID"))

    dgEmployees.Rea dOnly = True

    dgOrders.ReadOn ly = True

    dgOrderDetails. ReadOnly = True

    dgEmployees.Set DataBinding(ds, "Employee")

    dgOrders.SetDat aBinding(ds, "Employee.Emplo yeeOrder")

    dgOrderDetails. SetDataBinding( ds, "Employee.Emplo yeeOrder.Order2 Details")

    End Sub



    Ken

    ----------------------------

    "rodchar" <rodchar@discus sions.microsoft .com> wrote in message
    news:537A7747-319E-441D-910E-08E5D7BDAF2E@mi crosoft.com...

    Hey all,

    I'm using Northwind Customers and Orders tables. And I'm trying to build a
    3-tier logical architecture app. My problem is I have a form that lists all
    the customers in a datagrid. I want to be able to click on a customer and
    show form 2 with the details of that customer and another datagrid of the
    orders below.

    I'm trying to pass just one business object that has the dataset wrapped in
    it. When I pass the business object to the second form I can't get the
    datagrid to sync with the selected customer. It keeps defaulting I guess to
    the first customer of the customers' table. How can I sync my orders
    datagrid
    with the selected customer?

    Thanks in advance,
    rodchar


    Comment

    • Ken Tucker [MVP]

      #3
      Re: master/details

      Hi,



      Ken
      ---------------------
      "rodchar" <rodchar@discus sions.microsoft .com> wrote in message
      news:1529BB2F-70F8-4240-8807-9410221B769B@mi crosoft.com...
      Well I have a working example of 2 datagrids on one form but if I pick a
      customer from a datagrid on form1 and open up form2 to show the orders for
      that customer in another datagrid I get lost in the concept.

      "Ken Tucker [MVP]" wrote:
      [color=blue]
      > Hi,
      >
      > Here is an example that uses datareleations to keep 3 grids in
      > sync.
      > Place 3 datagrid grids on the form dgorders, dgorderdetails, dgemployees.
      >
      >
      > Dim ds As DataSet
      >
      > Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
      > System.EventArg s) Handles MyBase.Load
      >
      > Dim daEmployees As OleDbDataAdapte r
      >
      > Dim daOrders As OleDbDataAdapte r
      >
      > Dim daOrderDetails As OleDbDataAdapte r
      >
      > Dim conn As OleDbConnection
      >
      > Dim strConn As String
      >
      > Dim strSQL As String
      >
      > Dim strItem As String
      >
      > Dim ctrl As Control
      >
      > For Each ctrl In Me.Controls
      >
      > If TypeOf ctrl Is DataGrid Then
      >
      > Dim dg As DataGrid = ctrl
      >
      > dg.AllowNavigat ion = False
      >
      > End If
      >
      > Next
      >
      > strConn = "Provider = Microsoft.Jet.O LEDB.4.0;"
      >
      > strConn &= "Data Source = Northwind.mdb;"
      >
      >
      >
      > conn = New OleDbConnection (strConn)
      >
      > ds = New DataSet
      >
      > daEmployees = New OleDbDataAdapte r("Select * from Employees", conn)
      >
      > daOrders = New OleDbDataAdapte r("Select * from Orders", conn)
      >
      > daOrderDetails = New OleDbDataAdapte r("Select * from [Order Details]",
      > conn)
      >
      > daEmployees.Fil l(ds, "Employee")
      >
      > daOrders.Fill(d s, "Orders")
      >
      > daOrderDetails. Fill(ds, "OrderDetai ls")
      >
      > ds.Relations.Ad d("EmployeeOrde r",
      > ds.Tables("Empl oyee").Columns( "EmployeeID "), _
      >
      > ds.Tables("Orde rs").Columns("E mployeeID"))
      >
      > ds.Relations.Ad d("Order2Detail s", ds.Tables("Orde rs").Columns("O rderID"),
      > _
      >
      > ds.Tables("Orde rDetails").Colu mns("OrderID"))
      >
      > dgEmployees.Rea dOnly = True
      >
      > dgOrders.ReadOn ly = True
      >
      > dgOrderDetails. ReadOnly = True
      >
      > dgEmployees.Set DataBinding(ds, "Employee")
      >
      > dgOrders.SetDat aBinding(ds, "Employee.Emplo yeeOrder")
      >
      > dgOrderDetails. SetDataBinding( ds, "Employee.Emplo yeeOrder.Order2 Details")
      >
      > End Sub
      >
      >
      >
      > Ken
      >
      > ----------------------------
      >
      > "rodchar" <rodchar@discus sions.microsoft .com> wrote in message
      > news:537A7747-319E-441D-910E-08E5D7BDAF2E@mi crosoft.com...
      >
      > Hey all,
      >
      > I'm using Northwind Customers and Orders tables. And I'm trying to build a
      > 3-tier logical architecture app. My problem is I have a form that lists
      > all
      > the customers in a datagrid. I want to be able to click on a customer and
      > show form 2 with the details of that customer and another datagrid of the
      > orders below.
      >
      > I'm trying to pass just one business object that has the dataset wrapped
      > in
      > it. When I pass the business object to the second form I can't get the
      > datagrid to sync with the selected customer. It keeps defaulting I guess
      > to
      > the first customer of the customers' table. How can I sync my orders
      > datagrid
      > with the selected customer?
      >
      > Thanks in advance,
      > rodchar
      >
      >
      >[/color]


      Comment

      • Ken Tucker [MVP]

        #4
        Re: master/details

        Hi,



        Ken
        ---------------
        "rodchar" <rodchar@discus sions.microsoft .com> wrote in message
        news:F62320FE-49D2-490E-8CEE-2593B0460549@mi crosoft.com...
        I've seen this example before. I remember a slight problem I had which was
        when I got the child rows in the data row array I tried to bind that to a
        datagrid. It kinda worked in that I got extra fields such as "Has Error",
        "Row state", etc. and I tried to use the Table Styles but that didn't seem
        to
        affect it.

        Now, Cor gave some advice to me about this and I'm currently reviewing it. I
        think the advice he gave is kinda over my head but I'm trying. I'll let you
        know.

        thanks,
        rodchar

        "Ken Tucker [MVP]" wrote:
        [color=blue]
        > Hi,
        >
        > http://msdn.microsoft.com/library/de...dRowsTopic.asp
        >
        > Ken
        > ---------------------
        > "rodchar" <rodchar@discus sions.microsoft .com> wrote in message
        > news:1529BB2F-70F8-4240-8807-9410221B769B@mi crosoft.com...
        > Well I have a working example of 2 datagrids on one form but if I pick a
        > customer from a datagrid on form1 and open up form2 to show the orders for
        > that customer in another datagrid I get lost in the concept.
        >
        > "Ken Tucker [MVP]" wrote:
        >[color=green]
        > > Hi,
        > >
        > > Here is an example that uses datareleations to keep 3 grids in
        > > sync.
        > > Place 3 datagrid grids on the form dgorders, dgorderdetails,
        > > dgemployees.
        > >
        > >
        > > Dim ds As DataSet
        > >
        > > Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
        > > System.EventArg s) Handles MyBase.Load
        > >
        > > Dim daEmployees As OleDbDataAdapte r
        > >
        > > Dim daOrders As OleDbDataAdapte r
        > >
        > > Dim daOrderDetails As OleDbDataAdapte r
        > >
        > > Dim conn As OleDbConnection
        > >
        > > Dim strConn As String
        > >
        > > Dim strSQL As String
        > >
        > > Dim strItem As String
        > >
        > > Dim ctrl As Control
        > >
        > > For Each ctrl In Me.Controls
        > >
        > > If TypeOf ctrl Is DataGrid Then
        > >
        > > Dim dg As DataGrid = ctrl
        > >
        > > dg.AllowNavigat ion = False
        > >
        > > End If
        > >
        > > Next
        > >
        > > strConn = "Provider = Microsoft.Jet.O LEDB.4.0;"
        > >
        > > strConn &= "Data Source = Northwind.mdb;"
        > >
        > >
        > >
        > > conn = New OleDbConnection (strConn)
        > >
        > > ds = New DataSet
        > >
        > > daEmployees = New OleDbDataAdapte r("Select * from Employees", conn)
        > >
        > > daOrders = New OleDbDataAdapte r("Select * from Orders", conn)
        > >
        > > daOrderDetails = New OleDbDataAdapte r("Select * from [Order Details]",
        > > conn)
        > >
        > > daEmployees.Fil l(ds, "Employee")
        > >
        > > daOrders.Fill(d s, "Orders")
        > >
        > > daOrderDetails. Fill(ds, "OrderDetai ls")
        > >
        > > ds.Relations.Ad d("EmployeeOrde r",
        > > ds.Tables("Empl oyee").Columns( "EmployeeID "), _
        > >
        > > ds.Tables("Orde rs").Columns("E mployeeID"))
        > >
        > > ds.Relations.Ad d("Order2Detail s",
        > > ds.Tables("Orde rs").Columns("O rderID"),
        > > _
        > >
        > > ds.Tables("Orde rDetails").Colu mns("OrderID"))
        > >
        > > dgEmployees.Rea dOnly = True
        > >
        > > dgOrders.ReadOn ly = True
        > >
        > > dgOrderDetails. ReadOnly = True
        > >
        > > dgEmployees.Set DataBinding(ds, "Employee")
        > >
        > > dgOrders.SetDat aBinding(ds, "Employee.Emplo yeeOrder")
        > >
        > > dgOrderDetails. SetDataBinding( ds,
        > > "Employee.Emplo yeeOrder.Order2 Details")
        > >
        > > End Sub
        > >
        > >
        > >
        > > Ken
        > >
        > > ----------------------------
        > >
        > > "rodchar" <rodchar@discus sions.microsoft .com> wrote in message
        > > news:537A7747-319E-441D-910E-08E5D7BDAF2E@mi crosoft.com...
        > >
        > > Hey all,
        > >
        > > I'm using Northwind Customers and Orders tables. And I'm trying to build
        > > a
        > > 3-tier logical architecture app. My problem is I have a form that lists
        > > all
        > > the customers in a datagrid. I want to be able to click on a customer
        > > and
        > > show form 2 with the details of that customer and another datagrid of
        > > the
        > > orders below.
        > >
        > > I'm trying to pass just one business object that has the dataset wrapped
        > > in
        > > it. When I pass the business object to the second form I can't get the
        > > datagrid to sync with the selected customer. It keeps defaulting I guess
        > > to
        > > the first customer of the customers' table. How can I sync my orders
        > > datagrid
        > > with the selected customer?
        > >
        > > Thanks in advance,
        > > rodchar
        > >
        > >
        > >[/color]
        >
        >
        >[/color]


        Comment

        • rodchar

          #5
          Re: master/details

          Well I have a working example of 2 datagrids on one form but if I pick a
          customer from a datagrid on form1 and open up form2 to show the orders for
          that customer in another datagrid I get lost in the concept.

          "Ken Tucker [MVP]" wrote:
          [color=blue]
          > Hi,
          >
          > Here is an example that uses datareleations to keep 3 grids in sync.
          > Place 3 datagrid grids on the form dgorders, dgorderdetails, dgemployees.
          >
          >
          > Dim ds As DataSet
          >
          > Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
          > System.EventArg s) Handles MyBase.Load
          >
          > Dim daEmployees As OleDbDataAdapte r
          >
          > Dim daOrders As OleDbDataAdapte r
          >
          > Dim daOrderDetails As OleDbDataAdapte r
          >
          > Dim conn As OleDbConnection
          >
          > Dim strConn As String
          >
          > Dim strSQL As String
          >
          > Dim strItem As String
          >
          > Dim ctrl As Control
          >
          > For Each ctrl In Me.Controls
          >
          > If TypeOf ctrl Is DataGrid Then
          >
          > Dim dg As DataGrid = ctrl
          >
          > dg.AllowNavigat ion = False
          >
          > End If
          >
          > Next
          >
          > strConn = "Provider = Microsoft.Jet.O LEDB.4.0;"
          >
          > strConn &= "Data Source = Northwind.mdb;"
          >
          >
          >
          > conn = New OleDbConnection (strConn)
          >
          > ds = New DataSet
          >
          > daEmployees = New OleDbDataAdapte r("Select * from Employees", conn)
          >
          > daOrders = New OleDbDataAdapte r("Select * from Orders", conn)
          >
          > daOrderDetails = New OleDbDataAdapte r("Select * from [Order Details]", conn)
          >
          > daEmployees.Fil l(ds, "Employee")
          >
          > daOrders.Fill(d s, "Orders")
          >
          > daOrderDetails. Fill(ds, "OrderDetai ls")
          >
          > ds.Relations.Ad d("EmployeeOrde r",
          > ds.Tables("Empl oyee").Columns( "EmployeeID "), _
          >
          > ds.Tables("Orde rs").Columns("E mployeeID"))
          >
          > ds.Relations.Ad d("Order2Detail s", ds.Tables("Orde rs").Columns("O rderID"), _
          >
          > ds.Tables("Orde rDetails").Colu mns("OrderID"))
          >
          > dgEmployees.Rea dOnly = True
          >
          > dgOrders.ReadOn ly = True
          >
          > dgOrderDetails. ReadOnly = True
          >
          > dgEmployees.Set DataBinding(ds, "Employee")
          >
          > dgOrders.SetDat aBinding(ds, "Employee.Emplo yeeOrder")
          >
          > dgOrderDetails. SetDataBinding( ds, "Employee.Emplo yeeOrder.Order2 Details")
          >
          > End Sub
          >
          >
          >
          > Ken
          >
          > ----------------------------
          >
          > "rodchar" <rodchar@discus sions.microsoft .com> wrote in message
          > news:537A7747-319E-441D-910E-08E5D7BDAF2E@mi crosoft.com...
          >
          > Hey all,
          >
          > I'm using Northwind Customers and Orders tables. And I'm trying to build a
          > 3-tier logical architecture app. My problem is I have a form that lists all
          > the customers in a datagrid. I want to be able to click on a customer and
          > show form 2 with the details of that customer and another datagrid of the
          > orders below.
          >
          > I'm trying to pass just one business object that has the dataset wrapped in
          > it. When I pass the business object to the second form I can't get the
          > datagrid to sync with the selected customer. It keeps defaulting I guess to
          > the first customer of the customers' table. How can I sync my orders
          > datagrid
          > with the selected customer?
          >
          > Thanks in advance,
          > rodchar
          >
          >
          >[/color]

          Comment

          • rodchar

            #6
            Re: master/details

            Well I have a working example of 2 datagrids on one form but if I pick a
            customer from a datagrid on form1 and open up form2 to show the orders for
            that customer in another datagrid I get lost in the concept.

            "Ken Tucker [MVP]" wrote:
            [color=blue]
            > Hi,
            >
            > Here is an example that uses datareleations to keep 3 grids in sync.
            > Place 3 datagrid grids on the form dgorders, dgorderdetails, dgemployees.
            >
            >
            > Dim ds As DataSet
            >
            > Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
            > System.EventArg s) Handles MyBase.Load
            >
            > Dim daEmployees As OleDbDataAdapte r
            >
            > Dim daOrders As OleDbDataAdapte r
            >
            > Dim daOrderDetails As OleDbDataAdapte r
            >
            > Dim conn As OleDbConnection
            >
            > Dim strConn As String
            >
            > Dim strSQL As String
            >
            > Dim strItem As String
            >
            > Dim ctrl As Control
            >
            > For Each ctrl In Me.Controls
            >
            > If TypeOf ctrl Is DataGrid Then
            >
            > Dim dg As DataGrid = ctrl
            >
            > dg.AllowNavigat ion = False
            >
            > End If
            >
            > Next
            >
            > strConn = "Provider = Microsoft.Jet.O LEDB.4.0;"
            >
            > strConn &= "Data Source = Northwind.mdb;"
            >
            >
            >
            > conn = New OleDbConnection (strConn)
            >
            > ds = New DataSet
            >
            > daEmployees = New OleDbDataAdapte r("Select * from Employees", conn)
            >
            > daOrders = New OleDbDataAdapte r("Select * from Orders", conn)
            >
            > daOrderDetails = New OleDbDataAdapte r("Select * from [Order Details]", conn)
            >
            > daEmployees.Fil l(ds, "Employee")
            >
            > daOrders.Fill(d s, "Orders")
            >
            > daOrderDetails. Fill(ds, "OrderDetai ls")
            >
            > ds.Relations.Ad d("EmployeeOrde r",
            > ds.Tables("Empl oyee").Columns( "EmployeeID "), _
            >
            > ds.Tables("Orde rs").Columns("E mployeeID"))
            >
            > ds.Relations.Ad d("Order2Detail s", ds.Tables("Orde rs").Columns("O rderID"), _
            >
            > ds.Tables("Orde rDetails").Colu mns("OrderID"))
            >
            > dgEmployees.Rea dOnly = True
            >
            > dgOrders.ReadOn ly = True
            >
            > dgOrderDetails. ReadOnly = True
            >
            > dgEmployees.Set DataBinding(ds, "Employee")
            >
            > dgOrders.SetDat aBinding(ds, "Employee.Emplo yeeOrder")
            >
            > dgOrderDetails. SetDataBinding( ds, "Employee.Emplo yeeOrder.Order2 Details")
            >
            > End Sub
            >
            >
            >
            > Ken
            >
            > ----------------------------
            >
            > "rodchar" <rodchar@discus sions.microsoft .com> wrote in message
            > news:537A7747-319E-441D-910E-08E5D7BDAF2E@mi crosoft.com...
            >
            > Hey all,
            >
            > I'm using Northwind Customers and Orders tables. And I'm trying to build a
            > 3-tier logical architecture app. My problem is I have a form that lists all
            > the customers in a datagrid. I want to be able to click on a customer and
            > show form 2 with the details of that customer and another datagrid of the
            > orders below.
            >
            > I'm trying to pass just one business object that has the dataset wrapped in
            > it. When I pass the business object to the second form I can't get the
            > datagrid to sync with the selected customer. It keeps defaulting I guess to
            > the first customer of the customers' table. How can I sync my orders
            > datagrid
            > with the selected customer?
            >
            > Thanks in advance,
            > rodchar
            >
            >
            >[/color]

            Comment

            • rodchar

              #7
              Re: master/details

              I've seen this example before. I remember a slight problem I had which was
              when I got the child rows in the data row array I tried to bind that to a
              datagrid. It kinda worked in that I got extra fields such as "Has Error",
              "Row state", etc. and I tried to use the Table Styles but that didn't seem to
              affect it.

              Now, Cor gave some advice to me about this and I'm currently reviewing it. I
              think the advice he gave is kinda over my head but I'm trying. I'll let you
              know.

              thanks,
              rodchar

              "Ken Tucker [MVP]" wrote:
              [color=blue]
              > Hi,
              >
              > http://msdn.microsoft.com/library/de...dRowsTopic.asp
              >
              > Ken
              > ---------------------
              > "rodchar" <rodchar@discus sions.microsoft .com> wrote in message
              > news:1529BB2F-70F8-4240-8807-9410221B769B@mi crosoft.com...
              > Well I have a working example of 2 datagrids on one form but if I pick a
              > customer from a datagrid on form1 and open up form2 to show the orders for
              > that customer in another datagrid I get lost in the concept.
              >
              > "Ken Tucker [MVP]" wrote:
              >[color=green]
              > > Hi,
              > >
              > > Here is an example that uses datareleations to keep 3 grids in
              > > sync.
              > > Place 3 datagrid grids on the form dgorders, dgorderdetails, dgemployees.
              > >
              > >
              > > Dim ds As DataSet
              > >
              > > Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
              > > System.EventArg s) Handles MyBase.Load
              > >
              > > Dim daEmployees As OleDbDataAdapte r
              > >
              > > Dim daOrders As OleDbDataAdapte r
              > >
              > > Dim daOrderDetails As OleDbDataAdapte r
              > >
              > > Dim conn As OleDbConnection
              > >
              > > Dim strConn As String
              > >
              > > Dim strSQL As String
              > >
              > > Dim strItem As String
              > >
              > > Dim ctrl As Control
              > >
              > > For Each ctrl In Me.Controls
              > >
              > > If TypeOf ctrl Is DataGrid Then
              > >
              > > Dim dg As DataGrid = ctrl
              > >
              > > dg.AllowNavigat ion = False
              > >
              > > End If
              > >
              > > Next
              > >
              > > strConn = "Provider = Microsoft.Jet.O LEDB.4.0;"
              > >
              > > strConn &= "Data Source = Northwind.mdb;"
              > >
              > >
              > >
              > > conn = New OleDbConnection (strConn)
              > >
              > > ds = New DataSet
              > >
              > > daEmployees = New OleDbDataAdapte r("Select * from Employees", conn)
              > >
              > > daOrders = New OleDbDataAdapte r("Select * from Orders", conn)
              > >
              > > daOrderDetails = New OleDbDataAdapte r("Select * from [Order Details]",
              > > conn)
              > >
              > > daEmployees.Fil l(ds, "Employee")
              > >
              > > daOrders.Fill(d s, "Orders")
              > >
              > > daOrderDetails. Fill(ds, "OrderDetai ls")
              > >
              > > ds.Relations.Ad d("EmployeeOrde r",
              > > ds.Tables("Empl oyee").Columns( "EmployeeID "), _
              > >
              > > ds.Tables("Orde rs").Columns("E mployeeID"))
              > >
              > > ds.Relations.Ad d("Order2Detail s", ds.Tables("Orde rs").Columns("O rderID"),
              > > _
              > >
              > > ds.Tables("Orde rDetails").Colu mns("OrderID"))
              > >
              > > dgEmployees.Rea dOnly = True
              > >
              > > dgOrders.ReadOn ly = True
              > >
              > > dgOrderDetails. ReadOnly = True
              > >
              > > dgEmployees.Set DataBinding(ds, "Employee")
              > >
              > > dgOrders.SetDat aBinding(ds, "Employee.Emplo yeeOrder")
              > >
              > > dgOrderDetails. SetDataBinding( ds, "Employee.Emplo yeeOrder.Order2 Details")
              > >
              > > End Sub
              > >
              > >
              > >
              > > Ken
              > >
              > > ----------------------------
              > >
              > > "rodchar" <rodchar@discus sions.microsoft .com> wrote in message
              > > news:537A7747-319E-441D-910E-08E5D7BDAF2E@mi crosoft.com...
              > >
              > > Hey all,
              > >
              > > I'm using Northwind Customers and Orders tables. And I'm trying to build a
              > > 3-tier logical architecture app. My problem is I have a form that lists
              > > all
              > > the customers in a datagrid. I want to be able to click on a customer and
              > > show form 2 with the details of that customer and another datagrid of the
              > > orders below.
              > >
              > > I'm trying to pass just one business object that has the dataset wrapped
              > > in
              > > it. When I pass the business object to the second form I can't get the
              > > datagrid to sync with the selected customer. It keeps defaulting I guess
              > > to
              > > the first customer of the customers' table. How can I sync my orders
              > > datagrid
              > > with the selected customer?
              > >
              > > Thanks in advance,
              > > rodchar
              > >
              > >
              > >[/color]
              >
              >
              >[/color]

              Comment

              • rodchar

                #8
                Re: master/details

                I've seen this example before. I remember a slight problem I had which was
                when I got the child rows in the data row array I tried to bind that to a
                datagrid. It kinda worked in that I got extra fields such as "Has Error",
                "Row state", etc. and I tried to use the Table Styles but that didn't seem to
                affect it.

                Now, Cor gave some advice to me about this and I'm currently reviewing it. I
                think the advice he gave is kinda over my head but I'm trying. I'll let you
                know.

                thanks,
                rodchar

                "Ken Tucker [MVP]" wrote:
                [color=blue]
                > Hi,
                >
                > http://msdn.microsoft.com/library/de...dRowsTopic.asp
                >
                > Ken
                > ---------------------
                > "rodchar" <rodchar@discus sions.microsoft .com> wrote in message
                > news:1529BB2F-70F8-4240-8807-9410221B769B@mi crosoft.com...
                > Well I have a working example of 2 datagrids on one form but if I pick a
                > customer from a datagrid on form1 and open up form2 to show the orders for
                > that customer in another datagrid I get lost in the concept.
                >
                > "Ken Tucker [MVP]" wrote:
                >[color=green]
                > > Hi,
                > >
                > > Here is an example that uses datareleations to keep 3 grids in
                > > sync.
                > > Place 3 datagrid grids on the form dgorders, dgorderdetails, dgemployees.
                > >
                > >
                > > Dim ds As DataSet
                > >
                > > Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
                > > System.EventArg s) Handles MyBase.Load
                > >
                > > Dim daEmployees As OleDbDataAdapte r
                > >
                > > Dim daOrders As OleDbDataAdapte r
                > >
                > > Dim daOrderDetails As OleDbDataAdapte r
                > >
                > > Dim conn As OleDbConnection
                > >
                > > Dim strConn As String
                > >
                > > Dim strSQL As String
                > >
                > > Dim strItem As String
                > >
                > > Dim ctrl As Control
                > >
                > > For Each ctrl In Me.Controls
                > >
                > > If TypeOf ctrl Is DataGrid Then
                > >
                > > Dim dg As DataGrid = ctrl
                > >
                > > dg.AllowNavigat ion = False
                > >
                > > End If
                > >
                > > Next
                > >
                > > strConn = "Provider = Microsoft.Jet.O LEDB.4.0;"
                > >
                > > strConn &= "Data Source = Northwind.mdb;"
                > >
                > >
                > >
                > > conn = New OleDbConnection (strConn)
                > >
                > > ds = New DataSet
                > >
                > > daEmployees = New OleDbDataAdapte r("Select * from Employees", conn)
                > >
                > > daOrders = New OleDbDataAdapte r("Select * from Orders", conn)
                > >
                > > daOrderDetails = New OleDbDataAdapte r("Select * from [Order Details]",
                > > conn)
                > >
                > > daEmployees.Fil l(ds, "Employee")
                > >
                > > daOrders.Fill(d s, "Orders")
                > >
                > > daOrderDetails. Fill(ds, "OrderDetai ls")
                > >
                > > ds.Relations.Ad d("EmployeeOrde r",
                > > ds.Tables("Empl oyee").Columns( "EmployeeID "), _
                > >
                > > ds.Tables("Orde rs").Columns("E mployeeID"))
                > >
                > > ds.Relations.Ad d("Order2Detail s", ds.Tables("Orde rs").Columns("O rderID"),
                > > _
                > >
                > > ds.Tables("Orde rDetails").Colu mns("OrderID"))
                > >
                > > dgEmployees.Rea dOnly = True
                > >
                > > dgOrders.ReadOn ly = True
                > >
                > > dgOrderDetails. ReadOnly = True
                > >
                > > dgEmployees.Set DataBinding(ds, "Employee")
                > >
                > > dgOrders.SetDat aBinding(ds, "Employee.Emplo yeeOrder")
                > >
                > > dgOrderDetails. SetDataBinding( ds, "Employee.Emplo yeeOrder.Order2 Details")
                > >
                > > End Sub
                > >
                > >
                > >
                > > Ken
                > >
                > > ----------------------------
                > >
                > > "rodchar" <rodchar@discus sions.microsoft .com> wrote in message
                > > news:537A7747-319E-441D-910E-08E5D7BDAF2E@mi crosoft.com...
                > >
                > > Hey all,
                > >
                > > I'm using Northwind Customers and Orders tables. And I'm trying to build a
                > > 3-tier logical architecture app. My problem is I have a form that lists
                > > all
                > > the customers in a datagrid. I want to be able to click on a customer and
                > > show form 2 with the details of that customer and another datagrid of the
                > > orders below.
                > >
                > > I'm trying to pass just one business object that has the dataset wrapped
                > > in
                > > it. When I pass the business object to the second form I can't get the
                > > datagrid to sync with the selected customer. It keeps defaulting I guess
                > > to
                > > the first customer of the customers' table. How can I sync my orders
                > > datagrid
                > > with the selected customer?
                > >
                > > Thanks in advance,
                > > rodchar
                > >
                > >
                > >[/color]
                >
                >
                >[/color]

                Comment

                Working...