Q: GetChildRows

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

    Q: GetChildRows

    Hi

    A question has just occurred to me.

    I can get the child rows in a relationship using GetChildRows. Further, I
    can do something like:

    For Each child As DataRow In parent.GetChild Rows("Relations hip1")
    ......
    Next

    What I'd like to know is how to return the same rows but sorted in some
    manner. For example, in reverse order or sorted by a date field in the child
    row.

    I know I can get the rows using a Select statement BUT I'm wondering if I
    can achieve a "sorting" of the children using the technique above.

    Does anybody have any ideas?

    G


  • Charlie Brown

    #2
    Re: Q: GetChildRows

    It depends how your relationships are setup and when you want to sort,
    but you can use Table Views to do some of this.

    myDataTable.Def aultView.Sort = "ColumnName DESC"

    where the Sort expression is similar to what you would use in SQL.


    G .Net wrote:
    Hi
    >
    A question has just occurred to me.
    >
    I can get the child rows in a relationship using GetChildRows. Further, I
    can do something like:
    >
    For Each child As DataRow In parent.GetChild Rows("Relations hip1")
    .....
    Next
    >
    What I'd like to know is how to return the same rows but sorted in some
    manner. For example, in reverse order or sorted by a date field in the child
    row.
    >
    I know I can get the rows using a Select statement BUT I'm wondering if I
    can achieve a "sorting" of the children using the technique above.
    >
    Does anybody have any ideas?
    >
    G

    Comment

    • G .Net

      #3
      Re: Q: GetChildRows

      Hi Charlie

      I thought your suggestion looked like the solution when I first saw it.
      Unfortunately it didn't work :(

      Basically, I tried setting the default view of the child table to sort first
      on one of its columns. However, the order of the child rows returned in the
      code below does not appear to alter for the code below:

      For Each child As DataRow In parent.GetChild Rows("Relations hip1")

      Next

      Can you be of any further help?

      Thanks again


      "Charlie Brown" <cbrown@duclaw. comwrote in message
      news:1159985896 .588851.54280@c 28g2000cwb.goog legroups.com...
      It depends how your relationships are setup and when you want to sort,
      but you can use Table Views to do some of this.
      >
      myDataTable.Def aultView.Sort = "ColumnName DESC"
      >
      where the Sort expression is similar to what you would use in SQL.
      >
      >
      G .Net wrote:
      >Hi
      >>
      >A question has just occurred to me.
      >>
      >I can get the child rows in a relationship using GetChildRows. Further, I
      >can do something like:
      >>
      >For Each child As DataRow In parent.GetChild Rows("Relations hip1")
      >.....
      >Next
      >>
      >What I'd like to know is how to return the same rows but sorted in some
      >manner. For example, in reverse order or sorted by a date field in the
      >child
      >row.
      >>
      >I know I can get the rows using a Select statement BUT I'm wondering if I
      >can achieve a "sorting" of the children using the technique above.
      >>
      >Does anybody have any ideas?
      >>
      >G
      >

      Comment

      Working...